/** * Main function * * @param string[] $argv Program parameters * * @return void * @throws Exception */ function main($argv) { $params = parseArgs($argv); applyConfigOverrides($params); if (empty($params['source']) || !is_string($params['source'])) { echo <<<EOT Usage: {$argv['0']} --source=... [...] Parameters: --source Repository id ('*' for all, separate multiple sources with commas) --exclude Repository id's to exclude when using '*' for source (separate multiple sources with commas) --from Override harvesting start date --until Override harvesting end date --all Harvest from beginning (overrides --from) --verbose Enable verbose output --override Override initial resumption token (e.g. to resume failed connection) --reharvest[=date] This is a full reharvest, delete all records that were not received during the harvesting (or were modified before [date]). Implies --all. --config.section.name=value Set configuration directive to given value overriding any setting in recordmanager.ini --lockfile=file Use a lock file to avoid executing the command multiple times in parallel (useful when running from crontab) EOT; exit(1); } $lockfile = isset($params['lockfile']) ? $params['lockfile'] : ''; $lockhandle = false; try { if (($lockhandle = acquireLock($lockfile)) === false) { die; } $manager = new RecordManager(true, isset($params['verbose']) ? $params['verbose'] : false); $from = isset($params['from']) ? $params['from'] : null; if (isset($params['all']) || isset($params['reharvest'])) { $from = '-'; } foreach (explode(',', $params['source']) as $source) { $manager->harvest($source, $from, isset($params['until']) ? $params['until'] : null, isset($params['override']) ? urldecode($params['override']) : '', isset($params['exclude']) ? $params['exclude'] : null, isset($params['reharvest']) ? $params['reharvest'] : ''); } } catch (Exception $e) { releaseLock($lockhandle); throw $e; } releaseLock($lockhandle); }
public function save(AbstractEntity $entity) { if ($entity->getStorageStructure() == AbstractEntity::DOCUMENT) { $dm = new DocumentManager(); $document = $entity->toDocument(); $dm->persist($document); } if ($entity->getStorageStructure() == AbstractEntity::RELATIONAL) { $rm = new RecordManager(); $record = $entity->toRecord(); $rm->save($record); } }
/** * Main function * * @param string[] $argv Program parameters * * @return void */ function main($argv) { $params = parseArgs($argv); applyConfigOverrides($params); if (empty($params['search'])) { echo <<<EOT Usage: {$argv['0']} --search=... Parameters: --search=[regexp] Search for a string in data sources and list the data source id's EOT; exit(1); } $manager = new RecordManager(true, isset($params['verbose']) ? $params['verbose'] : false); if (!empty($params['search'])) { $manager->searchDataSources($params['search']); } }
/** * Main function * * @param string[] $argv Program parameters * * @return void * @throws Exception */ function main($argv) { $params = parseArgs($argv); applyConfigOverrides($params); if (empty($params['file']) || empty($params['source'])) { echo <<<EOT Usage: {$argv['0']} --file=... --source=... [...] Parameters: --file The file or wildcard pattern of files of records --source Source ID --verbose Enable verbose output --config.section.name=value Set configuration directive to given value overriding any setting in recordmanager.ini --lockfile=file Use a lock file to avoid executing the command multiple times in parallel (useful when running from crontab) EOT; exit(1); } $lockfile = isset($params['lockfile']) ? $params['lockfile'] : ''; $lockhandle = false; try { if (($lockhandle = acquireLock($lockfile)) === false) { die; } $manager = new RecordManager(true, isset($params['verbose']) ? $params['verbose'] : false); $manager->loadFromFile($params['source'], $params['file']); } catch (Exception $e) { releaseLock($lockhandle); throw $e; } releaseLock($lockhandle); }
/** * Main function * * @param string[] $argv Program parameters * * @return void */ function main($argv) { $params = parseArgs($argv); applyConfigOverrides($params); if (empty($params['file'])) { echo <<<EOT Usage: {$argv['0']} --file=... [...] Parameters: --file=... The file for records --deleted=... The file for deleted record IDs --from=... From date where to start the export --verbose Enable verbose output --quiet Quiet, no output apart from the data --skip=... Skip x records to export only a "representative" subset --source=... Export only the given source(s) (separate multiple sources with commas) --single=... Export single record with the given id --xpath=... Export only records matching the XPath expression --config.section.name=... Set configuration directive to given value overriding any setting in recordmanager.ini --sortdedup Sort export file by dedup id --dedupid=... deduped = Add dedup id's to records that have duplicates always = Always add dedup id's to the records Otherwise dedup id's are not added to the records EOT; exit(1); } $manager = new RecordManager(true, isset($params['verbose']) ? $params['verbose'] : false); $manager->quiet = isset($params['quiet']) ? $params['quiet'] : false; $manager->exportRecords($params['file'], isset($params['deleted']) ? $params['deleted'] : '', isset($params['from']) ? $params['from'] : '', isset($params['skip']) ? $params['skip'] : 0, isset($params['source']) ? $params['source'] : '', isset($params['single']) ? $params['single'] : '', isset($params['xpath']) ? $params['xpath'] : '', isset($params['sortdedup']) ? $params['sortdedup'] : false, isset($params['dedupid']) ? $params['dedupid'] : ''); }
/** * builds asset in repository from assetinfo and records from recordlist * * @param array assetInfo * @param array recordList * @return asset or false on fatal error * @access public * @since 7/18/05 * */ function buildAsset($info) { $assetInfo = $info['assetInfo']; $recordList = $info['recordList']; $childAssetList = $info['childAssetList']; $buildOrderedSet = $info['buildOrderedSet']; $idManager = Services::getService("Id"); $mime = Services::getService("MIME"); $FILE_ID = $idManager->getId("FILE"); $FILE_DATA_ID = $idManager->getId("FILE_DATA"); $FILE_NAME_ID = $idManager->getId("FILE_NAME"); $MIME_TYPE_ID = $idManager->getId("MIME_TYPE"); $THUMBNAIL_DATA_ID = $idManager->getId("THUMBNAIL_DATA"); $THUMBNAIL_MIME_TYPE_ID = $idManager->getId("THUMBNAIL_MIME_TYPE"); $asset = $this->_destinationRepository->createAsset($assetInfo['displayName'], $assetInfo['description'], $assetInfo['type']); $assetId = $asset->getId(); // log creation if (Services::serviceRunning("Logging")) { $loggingManager = Services::getService("Logging"); $log = $loggingManager->getLogForWriting("Harmoni"); $formatType = new Type("logging", "edu.middlebury", "AgentsAndNodes", "A format in which the acting Agent[s] and the target nodes affected are specified."); $priorityType = new Type("logging", "edu.middlebury", "Event_Notice", "Normal Events."); $item = new AgentNodeEntryItem("Create Node", "Asset: " . $assetId->getIdString() . " created."); $item->addNodeId($assetId); $item->addNodeId($this->_destinationRepository->getId()); $log->appendLogWithTypes($item, $formatType, $priorityType); } $this->addGoodAssetId($asset->getId()); RecordManager::setCacheMode(false); if (is_array($recordList)) { foreach ($recordList as $entry) { $assetRecord = $asset->createRecord($entry['structureId']); $j = 0; // printpre("creating record for: "); printpre($entry['structureId']); foreach ($entry['partStructureIds'] as $id) { if (!$entry['structureId']->isEqual($FILE_ID)) { if (isset($entry['parts'][$j])) { if (is_array($entry['parts'][$j])) { for ($k = 0; $k < count($entry['parts'][$j]); $k++) { $assetRecord->createPart($id, $entry['parts'][$j][$k]); } } else { $assetRecord->createPart($id, $entry['parts'][$j]); } } $j++; } else { if ($entry['structureId']->isEqual($FILE_ID)) { $filename = basename(trim($entry['parts'][0])); $mimetype = $mime->getMIMETypeForFileName($filename); $assetRecord->createPart($FILE_DATA_ID, file_get_contents($this->_srcDir . $filename)); $assetRecord->createPart($FILE_NAME_ID, basename($filename)); $assetRecord->createPart($MIME_TYPE_ID, $mimetype); $imageProcessor = Services::getService("ImageProcessor"); if (isset($entry['parts'][1]) && $entry['parts'][1] != "") { $assetRecord->createPart($THUMBNAIL_DATA_ID, file_get_contents($this->_srcDir . $entry['parts'][1])); } else { if ($imageProcessor->isFormatSupported($mimetype)) { try { $thumbData = $imageProcessor->generateThumbnailData($mimetype, file_get_contents($this->_srcDir . $filename)); } catch (ImageProcessingFailedException $e) { $thumbData = null; } if ($thumbData) { $assetRecord->createPart($THUMBNAIL_DATA_ID, $thumbData); $assetRecord->createPart($THUMBNAIL_MIME_TYPE_ID, $imageProcessor->getThumbnailFormat()); } } } break; } } } } } if (!is_null($childAssetList)) { $stop = $this->assetBuildingIteration(new HarmoniIterator($childAssetList), $asset, $buildOrderedSet); if (!$stop) { return $stop; } // false } return $asset; }
$error = ""; $message = ""; if (!empty($_POST)) { $error = $pm->validatePasswords($_POST); if (empty($error)) { $pm->savePasswords($_POST); header("Location: DirectoryServer.php"); exit; } } echo $pm->generateCss(); echo $error; echo $pm->generatePasswordForm(); } else { //If the password file exists use controller logic $rm = new RecordManager(); $passwords = $pm->getPasswords(); $rm->expireRecords(); //If upload mode and uploadPassword matches if (!empty($_GET["query"]) && $_GET["query"] == "upload") { if (isset($_GET["uploadPassword"]) && md5($_GET["uploadPassword"]) == $passwords["uploadPassword"]) { //Use the following code to read post body. Not regular form posts which would be accessed with $_POST $postText = trim(file_get_contents('php://input')); $output = $rm->uploadRecords($postText); echo $output; } } elseif (!empty($_GET["query"]) && $_GET["query"] == "download") { if (isset($_GET["downloadPassword"]) && md5($_GET["downloadPassword"]) == $passwords["downloadPassword"]) { $output = $rm->downloadRecords(); echo $output; }
/** * Main function * * @param string[] $argv Program parameters * * @return void * @throws Exception */ function main($argv) { $params = parseArgs($argv); applyConfigOverrides($params); if (empty($params['func']) || !is_string($params['func'])) { echo <<<EOT Usage: {$argv['0']} --func=... [...] Parameters: --func renormalize|deduplicate|updatesolr|dump|dumpsolr|markdeleted |deletesource|deletesolr|optimizesolr|count|checkdedup|comparesolr |purgedeleted|markdedup --source Source ID to process (separate multiple sources with commas) --all Process all records regardless of their state (deduplicate, markdedup) or date (updatesolr) --from Override the date from which to run the update (updatesolr) --single Process only the given record id (deduplicate, updatesolr, dump) --nocommit Don't ask Solr to commit the changes (updatesolr) --field Field to analyze (count) --force Force deletesource to proceed even if deduplication is enabled for the source --verbose Enable verbose output for debugging --config.section.name=value Set configuration directive to given value overriding any setting in recordmanager.ini --lockfile=file Use a lock file to avoid executing the command multiple times in parallel (useful when running from crontab) --comparelog Record comparison output file. N.B. The file will be overwritten (comparesolr) --dumpprefix File name prefix to use when dumping records (dumpsolr). Default is "dumpsolr". --mapped If set, use values only after any mapping files are processed when counting records (count) --daystokeep=days How many last days to keep when purging deleted records (purgedeleted) EOT; exit(1); } $lockfile = isset($params['lockfile']) ? $params['lockfile'] : ''; $lockhandle = false; try { if (($lockhandle = acquireLock($lockfile)) === false) { die; } $manager = new RecordManager(true, isset($params['verbose']) ? $params['verbose'] : false); $sources = isset($params['source']) ? $params['source'] : ''; $single = isset($params['single']) ? $params['single'] : ''; $noCommit = isset($params['nocommit']) ? $params['nocommit'] : false; // Solr update, compare and dump can handle multiple sources at once if ($params['func'] == 'updatesolr' || $params['func'] == 'dumpsolr') { $date = isset($params['all']) ? '' : (isset($params['from']) ? $params['from'] : null); $dumpPrefix = $params['func'] == 'dumpsolr' ? isset($params['dumpprefix']) ? $params['dumpprefix'] : 'dumpsolr' : ''; $manager->updateSolrIndex($date, $sources, $single, $noCommit, '', $dumpPrefix); } elseif ($params['func'] == 'comparesolr') { $date = isset($params['all']) ? '' : (isset($params['from']) ? $params['from'] : null); $manager->updateSolrIndex($date, $sources, $single, $noCommit, isset($params['comparelog']) ? $params['comparelog'] : '-'); } else { foreach (explode(',', $sources) as $source) { switch ($params['func']) { case 'renormalize': $manager->renormalize($source, $single); break; case 'deduplicate': case 'markdedup': $manager->deduplicate($source, isset($params['all']) ? true : false, $single, $params['func'] == 'markdedup'); break; case 'dump': $manager->dumpRecord($single); break; case 'deletesource': $manager->deleteRecords($source, isset($params['force']) ? $params['force'] : false); break; case 'markdeleted': $manager->markDeleted($source); break; case 'deletesolr': $manager->deleteSolrRecords($source); break; case 'optimizesolr': $manager->optimizeSolr(); break; case 'count': $manager->countValues($source, isset($params['field']) ? $params['field'] : null, isset($params['mapped']) ? $params['mapped'] : false); break; case 'checkdedup': $manager->checkDedupRecords(); break; case 'purgedeleted': if (!isset($params['force']) || !$params['force']) { echo <<<EOT Purging of deleted records means that any further Solr updates don't include deletions. Use the --force parameter to indicate that this is ok. No records have been purged. EOT; exit(1); } $manager->purgeDeletedRecords(isset($params['daystokeep']) ? intval($params['daystokeep']) : 0); break; default: echo 'Unknown func: ' . $params['func'] . "\n"; exit(1); } } } } catch (Exception $e) { releaseLock($lockhandle); throw $e; } releaseLock($lockhandle); }
* but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @category DataManagement * @package RecordManager * @author Ere Maijala <*****@*****.**> * @author Eero Heikkinen <*****@*****.**> * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link https://github.com/KDK-Alli/RecordManager */ if (!isset($_REQUEST['source']) || !isset($_REQUEST['data'])) { die('Missing parameters'); } $format = isset($_REQUEST['format']) ? $_REQUEST['format'] : ''; $source = isset($_REQUEST['source']) ? $_REQUEST['source'] : ''; if (!preg_match('/^[\\w_]*$/', $format) || !preg_match('/^[\\w_]*$/', $source)) { die('Invalid parameters'); } $basePath = substr(__FILE__, 0, strrpos(__FILE__, DIRECTORY_SEPARATOR)); require_once 'classes/RecordManager.php'; $configArray = parse_ini_file($basePath . '/conf/recordmanager.ini', true); $configArray['dataSourceSettings'] = parse_ini_file($basePath . '/conf/datasources.ini', true); $manager = new RecordManager(); $record = $manager->previewRecord($_REQUEST['data'], $format, $source); header('Content-Type: application/json'); echo json_encode($record);
<?php require_once '../adminHeader.html'; ?> <?php require_once '../../models/book.php'; require_once '../../models/record.php'; if ($_SERVER['REQUEST_METHOD'] == 'GET') { $bookId = $_GET['bookId']; $book = BookManager::getBook($bookId); if ($books === false) { echo "<script>history.back();alert('没有数据');</script>"; return; } $records = RecordManager::searchRecordsWithPersonName($bookId); } ?> <!DOCTYPE html> <html lang="en"> <head> <?php require_once "../adminHead.php"; ?> </head> <body> <?php require_once "../adminNav.html";
<?php require_once '../adminHeader.html'; ?> <?php require_once '../../models/person.php'; require_once '../../models/record.php'; if ($_SERVER['REQUEST_METHOD'] == 'GET') { $personId = $_GET['personId']; $person = PersonManager::getPersonWithBorrowCount($personId); if ($person === false) { echo "<script>history.back();alert('没有数据');</script>"; return; } $records = RecordManager::searchRecordsWithBookName($personId); } ?> <!DOCTYPE html> <html lang="en"> <head> <?php require_once "../adminHead.php"; ?> </head> <body> <?php require_once "../adminNav.html";