From 4c6b2cd4d36f3ae5dd8afafc5bdd4f6e61d89d25 Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 1 Mar 2007 16:10:20 +0000 Subject: [PATCH] Merged the archive server into the storage server. Still might need an upgrade script to do the transfer of files. --- campcaster/etc/Makefile.in | 26 +- .../src/modules/archiveServer/etc/Makefile.in | 50 +-- .../src/modules/storageServer/var/LocStor.php | 379 ++++++++++++++++++ .../modules/storageServer/var/Transport.php | 30 +- .../storageServer/var/TransportRecord.php | 2 +- .../src/modules/storageServer/var/conf.php | 4 +- .../storageServer/var/conf.php.template | 4 +- .../storageServer/var/conf_only.php.template | 4 +- .../var/install/upgrade/upgrade-to-1.3.0.php | 37 ++ .../storageServer/var/xmlrpc/XR_LocStor.php | 198 +++++++++ .../storageServer/var/xmlrpc/xrLocStor.php | 134 ++++--- 11 files changed, 745 insertions(+), 123 deletions(-) create mode 100644 campcaster/src/modules/storageServer/var/install/upgrade/upgrade-to-1.3.0.php diff --git a/campcaster/etc/Makefile.in b/campcaster/etc/Makefile.in index 289b5b33d..00166cc2b 100644 --- a/campcaster/etc/Makefile.in +++ b/campcaster/etc/Makefile.in @@ -126,7 +126,7 @@ EVENT_SCHEDULER_DIR = ${MODULES_DIR}/eventScheduler SCHEDULER_CLIENT_DIR = ${MODULES_DIR}/schedulerClient WIDGETS_DIR = ${MODULES_DIR}/widgets ALIB_DIR = ${MODULES_DIR}/alib -ARCHIVE_SERVER_DIR = ${MODULES_DIR}/archiveServer +#ARCHIVE_SERVER_DIR = ${MODULES_DIR}/archiveServer GETID3_DIR = ${MODULES_DIR}/getid3 HTML_UI_DIR = ${MODULES_DIR}/htmlUI STORAGE_ADMIN_DIR = ${MODULES_DIR}/storageAdmin @@ -247,15 +247,15 @@ modules_setup: ${TMP_DIR}/modules_setup.stamp ${TMP_DIR}/modules_setup.stamp: cd ${ALIB_DIR} && ./configure --prefix=${prefix} \ PACKAGE_VERSION=${PACKAGE_VERSION} - cd ${ARCHIVE_SERVER_DIR} && \ - ./configure --prefix=${prefix} \ - --with-hostname=${HOSTNAME} \ - --with-www-port=${WWW_PORT} \ - --with-database-server=${DB_SERVER} \ - --with-database=${DATABASE} \ - --with-database-user=${DB_USER} \ - --with-database-password=${DB_PASSWORD} \ - PACKAGE_VERSION=${PACKAGE_VERSION} +# cd ${ARCHIVE_SERVER_DIR} && \ +# ./configure --prefix=${prefix} \ +# --with-hostname=${HOSTNAME} \ +# --with-www-port=${WWW_PORT} \ +# --with-database-server=${DB_SERVER} \ +# --with-database=${DATABASE} \ +# --with-database-user=${DB_USER} \ +# --with-database-password=${DB_PASSWORD} \ +# PACKAGE_VERSION=${PACKAGE_VERSION} cd ${GETID3_DIR} && ./configure --prefix=${prefix} \ PACKAGE_VERSION=${PACKAGE_VERSION} cd ${HTML_UI_DIR} && ./configure --prefix=${prefix} \ @@ -371,7 +371,7 @@ depclean: ${MAKE} -C ${WIDGETS_DIR} depclean ${MAKE} -C ${SCHEDULER_DIR} depclean ${MAKE} -C ${GLIVESUPPORT_DIR} depclean - -${MAKE} -C ${ARCHIVE_SERVER_DIR} depclean +# -${MAKE} -C ${ARCHIVE_SERVER_DIR} depclean -${MAKE} -C ${STORAGE_SERVER_DIR} depclean compile: ${TMP_DIR}/compile.stamp @@ -449,7 +449,7 @@ setup_install_dirs: install_modules: ${MAKE} -C ${ALIB_DIR} install - ${MAKE} -C ${ARCHIVE_SERVER_DIR} install +# ${MAKE} -C ${ARCHIVE_SERVER_DIR} install ${MAKE} -C ${GETID3_DIR} install ${MAKE} -C ${HTML_UI_DIR} install ${MAKE} -C ${STORAGE_ADMIN_DIR} install @@ -467,5 +467,5 @@ install_modules: install_products: ${MAKE} -C ${SCHEDULER_DIR} install ${MAKE} -C ${GLIVESUPPORT_DIR} install - + diff --git a/campcaster/src/modules/archiveServer/etc/Makefile.in b/campcaster/src/modules/archiveServer/etc/Makefile.in index 755693066..9cfb3fe89 100644 --- a/campcaster/src/modules/archiveServer/etc/Makefile.in +++ b/campcaster/src/modules/archiveServer/etc/Makefile.in @@ -132,25 +132,25 @@ REPLACE_SED_STRING="s/ls_lib_dir/${USR_LIB_DIR_S}/; \ all: doc: - ${DOXYGEN} ${DOXYGEN_CONFIG} +# ${DOXYGEN} ${DOXYGEN_CONFIG} clean: db_clean - ${RMDIR} ${STOR_DIR} - ${RMDIR} ${ACCESS_DIR} - ${RMDIR} ${TRANS_DIR} +# ${RMDIR} ${STOR_DIR} +# ${RMDIR} ${ACCESS_DIR} +# ${RMDIR} ${TRANS_DIR} docclean: - ${RMDIR} ${DOXYGEN_DIR}/html +# ${RMDIR} ${DOXYGEN_DIR}/html depclean: clean dist: - ${TAR_C} ${MODULE_NAME}${DATE}${DIST_EXT} * +# ${TAR_C} ${MODULE_NAME}${DATE}${DIST_EXT} * distclean: clean docclean testonly: ${TEST_RUNNER} - ${TEST_RUNNER} +# ${TEST_RUNNER} check: all #testonly @@ -158,39 +158,39 @@ check: all recheck: clean check install: - ${MKDIR} ${DEST_DIR} - ${MKDIR} ${DEST_DIR}/access - ${MKDIR} ${DEST_DIR}/install - ${MKDIR} ${DEST_DIR}/stor - ${MKDIR} ${DEST_DIR}/stor/buffer - ${MKDIR} ${DEST_DIR}/trans - ${MKDIR} ${DEST_DIR}/xmlrpc - ${CP} ${VAR_DIR}/*.{php,template} ${DEST_DIR} - ${CP} ${VAR_DIR}/install/*.php ${DEST_DIR}/install - ${CP} ${VAR_DIR}/xmlrpc/*.php ${DEST_DIR}/xmlrpc - ${CAT} ${VAR_DIR}/conf.php.template | ${SED} -e ${REPLACE_SED_STRING} \ - > ${DEST_DIR}/conf.php +# ${MKDIR} ${DEST_DIR} +# ${MKDIR} ${DEST_DIR}/access +# ${MKDIR} ${DEST_DIR}/install +# ${MKDIR} ${DEST_DIR}/stor +# ${MKDIR} ${DEST_DIR}/stor/buffer +# ${MKDIR} ${DEST_DIR}/trans +# ${MKDIR} ${DEST_DIR}/xmlrpc +# ${CP} ${VAR_DIR}/*.{php,template} ${DEST_DIR} +# ${CP} ${VAR_DIR}/install/*.php ${DEST_DIR}/install +# ${CP} ${VAR_DIR}/xmlrpc/*.php ${DEST_DIR}/xmlrpc +# ${CAT} ${VAR_DIR}/conf.php.template | ${SED} -e ${REPLACE_SED_STRING} \ +# > ${DEST_DIR}/conf.php + - #------------------------------------------------------------------------------- # Specific targets #------------------------------------------------------------------------------- storage: dir_setup db_init dir_setup: ${DOXYGEN_DIR} - bin/setupDirs.sh ${STOR_DIR} ${ACCESS_DIR} ${TRANS_DIR} ${BUFF_DIR} +# bin/setupDirs.sh ${STOR_DIR} ${ACCESS_DIR} ${TRANS_DIR} ${BUFF_DIR} db_init: - -cd var/install && php -q install.php +# -cd var/install && php -q install.php db_clean: - -cd var/install && php -q uninstall.php +# -cd var/install && php -q uninstall.php ${TMP_DIR}: - ${MKDIR} ${TMP_DIR} +# ${MKDIR} ${TMP_DIR} ${DOXYGEN_DIR}: - ${MKDIR} ${DOXYGEN_DIR} +# ${MKDIR} ${DOXYGEN_DIR} ${TEST_RUNNER}: diff --git a/campcaster/src/modules/storageServer/var/LocStor.php b/campcaster/src/modules/storageServer/var/LocStor.php index bba76f319..60651ea7a 100644 --- a/campcaster/src/modules/storageServer/var/LocStor.php +++ b/campcaster/src/modules/storageServer/var/LocStor.php @@ -1406,5 +1406,384 @@ class LocStor extends BasicStor { return CAMPCASTER_VERSION; } + + /** + * Open upload transport (from station to hub) + * + * @param string $sessid + * session id + * @param string $chsum + * checksum + * @return array + * hasharray with: + * url string: writable URL + * token string: PUT token + */ + function uploadOpen($sessid, $chsum) + { + $owner = Alib::GetSessUserId($sessid); + if (PEAR::isError($owner)) { + return $owner; + } + $res = $this->bsOpenPut($chsum, NULL, $owner); + if (PEAR::isError($res)) { + return $res; + } + return array('url'=>$res['url'], 'token'=>$res['token']); + } + + + /** + * Close upload transport + * + * @param string $token + * transport token + * @param string $trtype + * transport type + * @param array $pars + * transport parameters + * @return mixed + */ + function uploadClose($token, $trtype, $pars=array()) + { + $res = $this->bsClosePut($token); + if (PEAR::isError($res)) { + return $res; + } + extract($res); // fname, owner + switch ($trtype) { + case "audioclip": + $mdtoken = $pars['mdpdtoken']; + $res = $this->bsClosePut($mdtoken); + if (PEAR::isError($res)) { + return $res; + } + $mdfname = $res['fname']; + if ($gunid == '') { + $gunid = NULL; + } + $parid = $this->_getHomeDirId($owner); + if (PEAR::isError($parid)) { + return $parid; + } + $values = array( + "filename" => $pars['name'], + "filepath" => $fname, + "metadata" => $mdfname, + "gunid" => $pars['gunid'], + "filetype" => "audioclip" + ); + $storedFile = $this->bsPutFile($parid, $values); + if (PEAR::isError($storedFile)) { + return $storedFile; + } + $res = $storedFile->getId(); + @unlink($fname); + @unlink($mdfname); + break; + case "playlist": + if ($gunid == '') { + $gunid = NULL; + } + $parid = $this->_getHomeDirId($owner); + if (PEAR::isError($parid)) { + return $parid; + } + $values = array( + "filename" => $pars['name'], + "metadata" => $fname, + "gunid" => $pars['gunid'], + "filetype" => "playlist" + ); + $storedFile = $this->bsPutFile($parid, $values); + if (PEAR::isError($storedFile)) { + return $storedFile; + } + $res = $storedFile->getId(); + @unlink($fname); + break; + case "playlistPkg": + $chsum = md5_file($fname); + // importPlaylistOpen: + $res = $this->bsOpenPut($chsum, NULL, $owner); + if (PEAR::isError($res)) { + return $res; + } + $dest = $res['fname']; + $token = $res['token']; + copy($fname, $dest); + $r = $this->importPlaylistClose($token); + if (PEAR::isError($r)) { + return $r; + } + @unlink($fname); + return $r; + break; + case "searchjob": + $crits = file_get_contents($fname); + $criteria = unserialize($crits); + @unlink($fname); + $results = $this->localSearch($criteria); + if (PEAR::isError($results)) { + return $results; + } + $realfile = tempnam($this->accessDir, 'searchjob_'); + @chmod($realfile, 0660); + $len = file_put_contents($realfile, serialize($results)); + $acc = BasicStor::bsAccess($realfile, '', NULL, 'download'); + if (PEAR::isError($acc)) { + return $acc; + } + $url = BasicStor::GetUrlPart()."access/".basename($acc['fname']); + $chsum = md5_file($realfile); + $size = filesize($realfile); + $res = array( + 'url'=>$url, 'token'=>$acc['token'], + 'chsum'=>$chsum, 'size'=>$size, + 'filename'=>$filename + ); + return $res; + break; + case "metadata": + break; + default: + } + return $res; + } + + + /** + * Open download transport + * + * @param string $sessid + * session id + * @param string $trtype + * transport type + * @param array $pars + * transport parameters + * @return hasharray with: + * url string: writable URL + * token string: PUT token + */ + function downloadOpen($sessid, $trtype, $pars=array()) + { + global $CC_CONFIG; + switch ($trtype) { + case "unknown": + case "audioclip": + case "metadata": + case "playlist": + case "playlistPkg": + if (!isset($pars['gunid'])) { + return PEAR::raiseError("Archive::downloadOpen: gunid not set"); + } + break; + } + $gunid = $pars['gunid']; + // resolve trtype by object type: + if ( ($trtype == 'unknown') || ($trtype == 'playlistPkg') ) { + $trtype2 = BasicStor::GetType($gunid); + if (PEAR::isError($trtype2)) { + return $trtype2; + } + // required with content: + $trtype = ( ($trtype2 == 'playlist') && ($trtype == 'playlistPkg') ? + 'playlistPkg' : $trtype2); + //return PEAR::raiseError("Archive::downloadOpen: TT=$trtype TT2=$trtype2 G=$gunid"); + } + switch ($trtype) { + case "audioclip": + $res = $this->downloadRawAudioDataOpen($sessid, $gunid); + break; + case "metadata": + $res = $this->downloadMetadataOpen($sessid, $gunid); + break; + case "playlist": + $res = $this->accessPlaylist($sessid, $gunid); + break; + case "playlistPkg": + $res = $this->bsExportPlaylistOpen($gunid); + if (PEAR::isError($res)) { + return $res; + } + $tmpn = tempnam($CC_CONFIG['transDir'], 'plExport_'); + $plfpath = "$tmpn.lspl"; + copy($res['fname'], $plfpath); + $res = $this->bsExportPlaylistClose($res['token']); + if (PEAR::isError($res)) { + return $res; + } + $fname = "transported_playlist.lspl"; + $id = BasicStor::IdFromGunid($gunid); + $acc = BasicStor::bsAccess($plfpath, 'lspl', NULL, 'download'); + if (PEAR::isError($acc)) { + return $acc; + } + $url = BasicStor::GetUrlPart()."access/".basename($acc['fname']); + $chsum = md5_file($plfpath); + $size = filesize($plfpath); + $res = array( + 'url'=>$url, 'token'=>$acc['token'], + 'chsum'=>$chsum, 'size'=>$size, + 'filename'=>$fname + ); + break; + case "searchjob": + $res = $pars; + break; + case "file": + $res = array(); + break; + default: + return PEAR::raiseError("Archive::downloadOpen: NotImpl ($trtype)"); + } + if (PEAR::isError($res)) { + return $res; + } + switch ($trtype) { + case "audioclip": + case "metadata": + case "playlist": + case "playlistPkg": + $title = $this->bsGetTitle(NULL, $gunid); + break; + case "searchjob": + $title = 'searchjob'; + break; + case "file": + $title = 'regular file'; + break; + default: + } + $res['title'] = $title; + $res['trtype'] = $trtype; + return $res; + } + + + /** + * Close download transport + * + * @param string $token + * transport token + * @param string $trtype + * transport type + * @return array + * hasharray with: + * url string: writable URL + * token string: PUT token + */ + function downloadClose($token, $trtype) + { + switch ($trtype) { + case "audioclip": + $res = $this->downloadRawAudioDataClose($token); + if (PEAR::isError($res)) { + return $res; + } + return $res; + case "metadata": + $res = $this->downloadMetadataClose($token); + return $res; + case "playlist": + $res = $this->releasePlaylist(NULL/*$sessid*/, $token); + return $res; + case "playlistPkg": + $res = BasicStor::bsRelease($token, 'download'); + if (PEAR::isError($res)) { + return $res; + } + $realFname = $r['realFname']; + @unlink($realFname); + if (preg_match("|(plExport_[^\.]+)\.lspl$|", $realFname, $va)) { + list(,$tmpn) = $va; + $tmpn = $CC_CONFIG['transDir']."/$tmpn"; + if (file_exists($tmpn)) { + @unlink($tmpn); + } + } + return $res; + case "searchjob": + $res = BasicStor::bsRelease($token, 'download'); + return $res; + case "file": + return array(); + default: + return PEAR::raiseError("Archive::downloadClose: NotImpl ($trtype)"); + } + } + + + /** + * Prepare hub initiated transport + * + * @param string $target + * hostname of transport target + * @param string $trtype + * transport type + * @param string $direction + * 'up' | 'down' + * @param array $pars + * transport parameters + * @return mixed + */ + function prepareHubInitiatedTransfer( + $target, $trtype='file', $direction='up',$pars=array()) + { + $tr = new Transport($this); + $trec = TransportRecord::create($tr, $trtype, $direction, + array_merge($pars, array('target'=>$target))); + if (PEAR::isError($trec)) { + return $trec; + } + return TRUE; + } + + + /** + * List hub initiated transports + * + * @param string $target + * hostname of transport target + * @param string $direction + * 'up' | 'down' + * @param string $trtok + * transport token + * @return mixed + */ + function listHubInitiatedTransfers( + $target=NULL, $direction=NULL, $trtok=NULL) + { + $tr = new Transport($this); + $res = $tr->getTransports($direction, $target, $trtok); + return $res; + } + + + /** + * Set state of hub initiated transport + * + * @param string $target + * hostname of transport target + * @param string $trtok + * transport token + * @param string $state + * transport state + * @return TransportRecord|PEAR_Error + */ + function setHubInitiatedTransfer($target, $trtok, $state) + { + $tr = new Transport($this); + $trec = TransportRecord::recall($tr, $trtok); + if (PEAR::isError($trec)) { + return $trec; + } + $r = $trec->setState($state); + if (PEAR::isError($r)) { + return $r; + } + return $trec; + } + } // class LocStor ?> \ No newline at end of file diff --git a/campcaster/src/modules/storageServer/var/Transport.php b/campcaster/src/modules/storageServer/var/Transport.php index d1d8cf6eb..e2d820958 100644 --- a/campcaster/src/modules/storageServer/var/Transport.php +++ b/campcaster/src/modules/storageServer/var/Transport.php @@ -491,7 +491,7 @@ class Transport $res = file_get_contents($row['localfile']); $results = unserialize($res); if ($andClose) { - $ret = $this->xmlrpcCall('archive.downloadClose', + $ret = $this->xmlrpcCall('locstor.downloadClose', array( 'token' => $row['pdtoken'] , 'trtype' => $row['trtype'] , @@ -590,7 +590,7 @@ class Transport */ function getHubInitiatedTransfers() { - $ret = $this->xmlrpcCall('archive.listHubInitiatedTransfers', + $ret = $this->xmlrpcCall('locstor.listHubInitiatedTransfers', array('target' => HOSTNAME)); if (PEAR::isError($ret)) { return $ret; @@ -616,7 +616,7 @@ class Transport */ function startHubInitiatedTransfer($uid, $rtrtok) { - $ret = $this->xmlrpcCall('archive.listHubInitiatedTransfers', + $ret = $this->xmlrpcCall('locstor.listHubInitiatedTransfers', array( 'target' => HOSTNAME, 'trtok' => $rtrtok, @@ -690,7 +690,7 @@ class Transport "Transport::startHubInitiatedTransfer: ???" ); } - $ret = $this->xmlrpcCall('archive.setHubInitiatedTransfer', + $ret = $this->xmlrpcCall('locstor.setHubInitiatedTransfer', array( 'target' => HOSTNAME, 'trtok' => $rtrtok, @@ -716,7 +716,7 @@ class Transport function loginToArchive() { global $CC_CONFIG; - $res = $this->xmlrpcCall('archive.login', + $res = $this->xmlrpcCall('locstor.login', array( 'login' => $CC_CONFIG['archiveAccountLogin'], 'pass' => $CC_CONFIG['archiveAccountPass'] @@ -738,7 +738,7 @@ class Transport */ function logoutFromArchive($sessid) { - $res = $this->xmlrpcCall('archive.logout', + $res = $this->xmlrpcCall('locstor.logout', array('sessid'=>$sessid)); return $res; } @@ -962,7 +962,7 @@ class Transport if (PEAR::isError($trec)) { return $trec; } - $ret = $this->xmlrpcCall('archive.uploadOpen', + $ret = $this->xmlrpcCall('locstor.uploadOpen', array( 'sessid' => $asessid , 'chsum' => $row['expectedsum'], @@ -997,7 +997,7 @@ class Transport if (PEAR::isError($trec)) { return $trec; } - $ret = $this->xmlrpcCall('archive.downloadOpen', + $ret = $this->xmlrpcCall('locstor.downloadOpen', array( 'sessid'=> $asessid, 'trtype'=> $row['trtype'], @@ -1137,7 +1137,7 @@ class Transport } } else { // wrong md5 at finish - TODO: start again - // $this->xmlrpcCall('archive.uploadReset', array()); + // $this->xmlrpcCall('locstor.uploadReset', array()); $trec->fail('file uploaded with bad md5'); return PEAR::raiseError("Transport::cronUploadWaiting:". " file uploaded with bad md5 ". @@ -1282,7 +1282,7 @@ class Transport } else { $mdpdtoken = NULL; } - $ret = $this->xmlrpcCall('archive.uploadClose', + $ret = $this->xmlrpcCall('locstor.uploadClose', array( 'token' => $row['pdtoken'] , 'trtype' => $row['trtype'], @@ -1402,7 +1402,7 @@ class Transport return $storedFile; } $res = $storedFile->getId(); - $ret = $this->xmlrpcCall('archive.downloadClose', + $ret = $this->xmlrpcCall('locstor.downloadClose', array( 'token' => $mdtrec->row['pdtoken'] , 'trtype' => 'metadata' , @@ -1436,7 +1436,7 @@ class Transport return TRUE; // don't close - getSearchResults should close it break; } - $ret = $this->xmlrpcCall('archive.downloadClose', + $ret = $this->xmlrpcCall('locstor.downloadClose', array( 'token' => $row['pdtoken'] , 'trtype' => $row['trtype'] , @@ -1485,7 +1485,7 @@ class Transport return PEAR::raiseError("DEBUG: NotImpl ".var_export($row,TRUE)); } if (!is_null($rtrtok = $trec->row['rtrtok'])) { - $ret = $this->xmlrpcCall('archive.setHubInitiatedTransfer', + $ret = $this->xmlrpcCall('locstor.setHubInitiatedTransfer', array( 'target' => HOSTNAME, 'trtok' => $rtrtok, @@ -1616,7 +1616,7 @@ class Transport */ function uploadCheck($pdtoken) { - $ret = $this->xmlrpcCall('archive.uploadCheck', + $ret = $this->xmlrpcCall('locstor.uploadCheck', array('token'=>$pdtoken)); return $ret; } @@ -1630,7 +1630,7 @@ class Transport */ function pingToArchive() { - $res = $this->xmlrpcCall('archive.ping', + $res = $this->xmlrpcCall('locstor.ping', array('par'=>'ping_'.date('H:i:s'))); return $res; } diff --git a/campcaster/src/modules/storageServer/var/TransportRecord.php b/campcaster/src/modules/storageServer/var/TransportRecord.php index e93be402d..8804fa674 100644 --- a/campcaster/src/modules/storageServer/var/TransportRecord.php +++ b/campcaster/src/modules/storageServer/var/TransportRecord.php @@ -70,7 +70,7 @@ class TransportRecord * default parameters (optional, internal use) * @return TransportRecord */ - function create(&$tr, $trtype, $direction='up', $defaults=array()) + public static function create(&$tr, $trtype, $direction='up', $defaults=array()) { global $CC_DBC, $CC_CONFIG; $trec = new TransportRecord($tr); diff --git a/campcaster/src/modules/storageServer/var/conf.php b/campcaster/src/modules/storageServer/var/conf.php index ef845cceb..20dd584a2 100644 --- a/campcaster/src/modules/storageServer/var/conf.php +++ b/campcaster/src/modules/storageServer/var/conf.php @@ -69,8 +69,8 @@ $CC_CONFIG = array( 'storageUrlPort' => 80, /* ================================================ archive configuration */ - 'archiveUrlPath' => '/campcasterArchiveServer', - 'archiveXMLRPC' => 'xmlrpc/xrArchive.php', + 'archiveUrlPath' => '/campcasterStorageServer', + 'archiveXMLRPC' => 'xmlrpc/xrLocStor.php', 'archiveUrlHost' => 'localhost', 'archiveUrlPort' => 80, 'archiveAccountLogin' => 'root', diff --git a/campcaster/src/modules/storageServer/var/conf.php.template b/campcaster/src/modules/storageServer/var/conf.php.template index 2b5255a58..5febcc2c3 100644 --- a/campcaster/src/modules/storageServer/var/conf.php.template +++ b/campcaster/src/modules/storageServer/var/conf.php.template @@ -70,8 +70,8 @@ $CC_CONFIG = array( 'storageUrlPort' => ls_php_port, /* ================================================ archive configuration */ - 'archiveUrlPath' => 'ls_archiveUrlPath', - 'archiveXMLRPC' => 'xmlrpc/xrArchive.php', + 'archiveUrlPath' => 'ls_storageUrlPath', + 'archiveXMLRPC' => 'xmlrpc/xrLocStor.php', 'archiveUrlHost' => 'ls_php_host', 'archiveUrlPort' => ls_php_port, 'archiveAccountLogin' => 'root', diff --git a/campcaster/src/modules/storageServer/var/conf_only.php.template b/campcaster/src/modules/storageServer/var/conf_only.php.template index edd49f490..b1a8db3ab 100644 --- a/campcaster/src/modules/storageServer/var/conf_only.php.template +++ b/campcaster/src/modules/storageServer/var/conf_only.php.template @@ -43,8 +43,8 @@ $CC_CONFIG = array( 'storageUrlPort' => ls_php_port, /* ================================================ archive configuration */ - 'archiveUrlPath' => 'ls_archiveUrlPath', - 'archiveXMLRPC' => 'xmlrpc/xrArchive.php', + 'archiveUrlPath' => 'ls_storageUrlPath', + 'archiveXMLRPC' => 'xmlrpc/xrLocStor.php', 'archiveUrlHost' => 'ls_php_host', 'archiveUrlPort' => ls_php_port, 'archiveAccountLogin' => 'root', diff --git a/campcaster/src/modules/storageServer/var/install/upgrade/upgrade-to-1.3.0.php b/campcaster/src/modules/storageServer/var/install/upgrade/upgrade-to-1.3.0.php new file mode 100644 index 000000000..b7b98b8f2 --- /dev/null +++ b/campcaster/src/modules/storageServer/var/install/upgrade/upgrade-to-1.3.0.php @@ -0,0 +1,37 @@ + + * @version $Revision: 2834 $ + * @package Campcaster + * @subpackage StorageServer + * @copyright 2006 MDLF, Inc. + * @license http://www.gnu.org/licenses/gpl.txt + * @link http://www.campware.org + * + */ + +// Do not allow remote execution +$arr = array_diff_assoc($_SERVER, $_ENV); +if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) { + header("HTTP/1.1 400"); + header("Content-type: text/plain; charset=UTF-8"); + echo "400 Not executable\r\n"; + exit(1); +} + +echo "*********************************************\n"; +echo "* StorageServer Upgrade from 1.2.X to 1.3.0 *\n"; +echo "*********************************************\n"; + +require_once(dirname(__FILE__).'/../../conf.php'); +require_once(dirname(__FILE__)."/../installInit.php"); +campcaster_db_connect(); +require_once(dirname(__FILE__)."/../../StoredFile.php"); + +// Move audio clips from the archive to the local storage + +echo "*******************************************\n"; +echo "* StorageServer Upgrade to 1.3.0 Complete *\n"; +echo "*******************************************\n"; + +?> \ No newline at end of file diff --git a/campcaster/src/modules/storageServer/var/xmlrpc/XR_LocStor.php b/campcaster/src/modules/storageServer/var/xmlrpc/XR_LocStor.php index dbda3d119..ac0c3abfa 100644 --- a/campcaster/src/modules/storageServer/var/xmlrpc/XR_LocStor.php +++ b/campcaster/src/modules/storageServer/var/xmlrpc/XR_LocStor.php @@ -3596,6 +3596,204 @@ class XR_LocStor extends LocStor { ))); } + /** + * Simple ping method - return strtouppered string + * + * @param XML_RPC_Message $input + * @return XML_RPC_Response + */ + function xr_ping($input) + { + list($ok, $r) = XR_LocStor::xr_getParams($input); + if (!$ok) { + return $r; + } + $res = date("Ymd-H:i:s")." Network hub answer: {$r['par']}"; + return new XML_RPC_Response(XML_RPC_encode($res)); + } + + + /** + * @param XML_RPC_Message $input + * @return XML_RPC_Response + */ + function xr_uploadOpen($input) + { + list($ok, $r) = XR_LocStor::xr_getParams($input); + if (!$ok) { + return $r; + } + $res = $this->uploadOpen($r['sessid'], $r['chsum']); + if (PEAR::isError($res)) + return new XML_RPC_Response(0, 803, + "xr_uploadOpen: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + return new XML_RPC_Response(XML_RPC_encode($res)); + } + + + /** + * Check state of file upload + * + * @param XML_RPC_Message $input + * @return XML_RPC_Response + */ + function xr_uploadCheck($input) + { + list($ok, $r) = XR_LocStor::xr_getParams($input); + if (!$ok) { + return $r; + } + $res = $this->uploadCheck($r['token']); + if (PEAR::isError($res)) + return new XML_RPC_Response(0, 803, + "xr_uploadCheck: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + return new XML_RPC_Response(XML_RPC_encode($res)); + } + + + /** + * @param XML_RPC_Message $input + * @return XML_RPC_Response + */ + function xr_uploadClose($input) + { + list($ok, $r) = XR_LocStor::xr_getParams($input); + if (!$ok) { + return $r; + } + $res = $this->uploadClose($r['token'], $r['trtype'], $r['pars']); + if (PEAR::isError($res)) { + $code = 803; + // Special case for duplicate file - give back + // different error code so we can display nice user message. + if ($res->getCode() == GBERR_GUNID) { + $code = 888; + } + return new XML_RPC_Response(0, $code, + "xr_uploadClose: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + } + return new XML_RPC_Response(XML_RPC_encode($res)); + } + + + /** + * @param XML_RPC_Message $input + * @return XML_RPC_Response + */ + function xr_downloadOpen($input) + { + list($ok, $r) = XR_LocStor::xr_getParams($input); + if (!$ok) { + return $r; + } + $res = $this->downloadOpen($r['sessid'], $r['trtype'], $r['pars']); + if (PEAR::isError($res)) + return new XML_RPC_Response(0, 803, + "xr_downloadOpen: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + return new XML_RPC_Response(XML_RPC_encode($res)); + } + + + /** + * @param XML_RPC_Message $input + * @return XML_RPC_Response + */ + function xr_downloadClose($input) + { + list($ok, $r) = XR_LocStor::xr_getParams($input); + if (!$ok) { + return $r; + } + $res = $this->downloadClose($r['token'], $r['trtype']); + if (PEAR::isError($res)) + return new XML_RPC_Response(0, 803, + "xr_downloadClose: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + return new XML_RPC_Response(XML_RPC_encode($res)); + } + + + /** + * @param XML_RPC_Message $input + * @return XML_RPC_Response + */ + function xr_prepareHubInitiatedTransfer($input) + { + list($ok, $r) = XR_LocStor::xr_getParams($input); + if (!$ok) { + return $r; + } + foreach (array('trtype'=>NULL, 'direction'=>'up', 'pars'=>array()) as $k => $dv) { + if (!isset($r[$k])) { + $r[$k] = $dv; + } + } + $res = $this->prepareHubInitiatedTransfer( + $r['target'], $r['trtype'], $r['direction'], $r['pars']); + if (PEAR::isError($res)) + return new XML_RPC_Response(0, 803, + "xr_prepareHubInitiatedTransfer: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + return new XML_RPC_Response(XML_RPC_encode($res)); + } + + + /** + * @param XML_RPC_Message $input + * @return XML_RPC_Response + */ + function xr_listHubInitiatedTransfers($input) + { + list($ok, $r) = XR_LocStor::xr_getParams($input); + if (!$ok) { + return $r; + } + foreach (array('target'=>NULL, 'direction'=>NULL, 'trtok'=>NULL) as $k=>$dv) { + if (!isset($r[$k])) { + $r[$k] = $dv; + } + } + $res = $this->listHubInitiatedTransfers( + $r['target'], $r['direction'], $r['trtok']); + if (PEAR::isError($res)) + return new XML_RPC_Response(0, 803, + "xr_listHubInitiatedTransfers: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + return new XML_RPC_Response(XML_RPC_encode($res)); + } + + + /** + * @param XML_RPC_Message $input + * @return XML_RPC_Response + */ + function xr_setHubInitiatedTransfer($input) + { + list($ok, $r) = XR_LocStor::xr_getParams($input); + if (!$ok) { + return $r; + } + $res = $this->setHubInitiatedTransfer( + $r['target'], $r['trtok'], $r['state']); + if (PEAR::isError($res)) + return new XML_RPC_Response(0, 803, + "xr_setHubInitiatedTransfer: ".$res->getMessage(). + " ".$res->getUserInfo() + ); + return new XML_RPC_Response(XML_RPC_encode($res)); + } + /* ==================================================== "private" methods */ /** * Check and convert struct of parameters diff --git a/campcaster/src/modules/storageServer/var/xmlrpc/xrLocStor.php b/campcaster/src/modules/storageServer/var/xmlrpc/xrLocStor.php index 3bb833bed..8a297e2ff 100644 --- a/campcaster/src/modules/storageServer/var/xmlrpc/xrLocStor.php +++ b/campcaster/src/modules/storageServer/var/xmlrpc/xrLocStor.php @@ -64,97 +64,105 @@ $CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC); $locStor = new XR_LocStor(); $methods = array( - 'test' => 'Tests toupper and checks sessid, params: '. - 'teststring, sessid.', - 'getVersion' => 'Dummy function for connection testing.', - 'authenticate' => 'Checks authentication.', - 'login' => 'Login to storage.', - 'logout' => 'Logout from storage.', - 'existsAudioClip' => 'Checks if an Audio clip with the specified '. - 'id is stored in local storage.', - 'storeAudioClipOpen' => 'Open channel to store a new audio clip '. - 'or replace an existing one.', - 'storeAudioClipClose' => 'Close channel to store a new audio clip'. - ' or replace an existing one.', + 'test' => 'Tests toupper and checks sessid, params: teststring, sessid.', + 'getVersion' => 'Dummy function for connection testing.', + 'authenticate' => 'Checks authentication.', + 'login' => 'Login to storage.', + 'logout' => 'Logout from storage.', + 'existsAudioClip' => 'Checks if an Audio clip with the specified '. + 'id is stored in local storage.', + 'storeAudioClipOpen' => 'Open channel to store a new audio clip '. + 'or replace an existing one.', + 'storeAudioClipClose' => 'Close channel to store a new audio clip'. + ' or replace an existing one.', 'downloadRawAudioDataOpen'=> 'Create and return downloadable URL'. - 'for audio file', + 'for audio file', 'downloadRawAudioDataClose'=>'Discard downloadable URL for audio file', - 'downloadMetadataOpen' => 'Create and return downloadable URL'. - 'for metadata', - 'downloadMetadataClose' => 'Discard downloadable URL for metadata', - 'openPut' => 'openPut', - 'closePut' => 'closePut', - 'deleteAudioClip' => 'Delete an existing Audio clip.', + 'downloadMetadataOpen' => 'Create and return downloadable URL'. + 'for metadata', + 'downloadMetadataClose' => 'Discard downloadable URL for metadata', + 'openPut' => 'openPut', + 'closePut' => 'closePut', + 'deleteAudioClip' => 'Delete an existing Audio clip.', 'updateAudioClipMetadata' => 'Update the metadata of an Audio clip '. 'stored in Local storage.', - 'searchMetadata' => 'Search through the metadata of stored '. + 'searchMetadata' => 'Search through the metadata of stored '. 'files, return all matching clip ids.', - 'browseCategory' =>'Return values of specified metadata category.', - 'accessRawAudioData' => 'Get access to raw audio data.', - 'releaseRawAudioData' => 'Release access to raw audio data.', - 'getAudioClip' => 'Return the contents of an Audio clip.', - 'resetStorage' => 'Reset storageServer for debugging.', - 'storeWebstream' => 'Store audio stream identified by URL', + 'browseCategory' =>'Return values of specified metadata category.', + 'accessRawAudioData' => 'Get access to raw audio data.', + 'releaseRawAudioData' => 'Release access to raw audio data.', + 'getAudioClip' => 'Return the contents of an Audio clip.', + 'resetStorage' => 'Reset storageServer for debugging.', + 'storeWebstream' => 'Store audio stream identified by URL', - 'createPlaylist' => 'Create a new Playlist metafile.', - 'editPlaylist' => 'Open a Playlist metafile for editing.', - 'savePlaylist' => 'Save a Playlist metafile.', - 'revertEditedPlaylist' => 'RollBack playlist changes to the locked state.', - 'deletePlaylist' => 'Delete a Playlist metafile.', - 'accessPlaylist' => 'Open readable URL to a Playlist metafile.', - 'releasePlaylist' => 'Release readable URL from accessPlaylist.', - 'existsPlaylist' => 'Check whether a Playlist exists.', - 'playlistIsAvailable' => 'Check whether a Playlist is available '. - 'for editing.', - 'exportPlaylistOpen' => 'Create a tarfile with playlist export.', - 'exportPlaylistClose' => 'Close playlist export.', - 'importPlaylistOpen' => 'Open writable handle for playlist import.', - 'importPlaylistClose' => 'Close import-handle and import playlist.', + 'createPlaylist' => 'Create a new Playlist metafile.', + 'editPlaylist' => 'Open a Playlist metafile for editing.', + 'savePlaylist' => 'Save a Playlist metafile.', + 'revertEditedPlaylist' => 'RollBack playlist changes to the locked state.', + 'deletePlaylist' => 'Delete a Playlist metafile.', + 'accessPlaylist' => 'Open readable URL to a Playlist metafile.', + 'releasePlaylist' => 'Release readable URL from accessPlaylist.', + 'existsPlaylist' => 'Check whether a Playlist exists.', + 'playlistIsAvailable' => 'Check whether a Playlist is available '. + 'for editing.', + 'exportPlaylistOpen' => 'Create a tarfile with playlist export.', + 'exportPlaylistClose' => 'Close playlist export.', + 'importPlaylistOpen' => 'Open writable handle for playlist import.', + 'importPlaylistClose' => 'Close import-handle and import playlist.', - 'renderPlaylistToFileOpen' => 'Render playlist to ogg file (open handle)', + 'renderPlaylistToFileOpen' => 'Render playlist to ogg file (open handle)', 'renderPlaylistToFileCheck' => 'Render playlist to ogg file (check results)', 'renderPlaylistToFileClose' => 'Render playlist to ogg file (close handle)', - 'renderPlaylistToStorageOpen' => 'Render playlist to storage media clip (open handle)', - 'renderPlaylistToStorageCheck' => 'Render playlist to storage media clip (check results)', + 'renderPlaylistToStorageOpen' => 'Render playlist to storage media clip (open handle)', + 'renderPlaylistToStorageCheck' => 'Render playlist to storage media clip (check results)', - 'renderPlaylistToRSSOpen' => 'Render playlist to RSS file (open handle)', - 'renderPlaylistToRSSCheck' => 'Render playlist to RSS file (check results)', - 'renderPlaylistToRSSClose' => 'Render playlist to RSS file (close handle)', + 'renderPlaylistToRSSOpen' => 'Render playlist to RSS file (open handle)', + 'renderPlaylistToRSSCheck' => 'Render playlist to RSS file (check results)', + 'renderPlaylistToRSSClose' => 'Render playlist to RSS file (close handle)', - 'createBackupOpen' => 'Create backup of storage (open handle)', + 'createBackupOpen' => 'Create backup of storage (open handle)', 'createBackupCheck' => 'Create backup of storage (check results)', 'createBackupClose' => 'Create backup of storage (close handle)', - 'restoreBackupOpen' => 'Restore a backup file (open handle)', + 'restoreBackupOpen' => 'Restore a backup file (open handle)', 'restoreBackupClosePut' => 'Restore a backup file (close PUT handle)', 'restoreBackupCheck' => 'Restore a backup file (check results)', 'restoreBackupClose' => 'Restore a backup file (close handle)', - 'loadPref' => 'Load user preference value.', - 'savePref' => 'Save user preference value.', - 'delPref' => 'Delete user preference record.', - 'loadGroupPref' => 'Read group preference record.', - 'saveGroupPref' => 'Delete user preference record.', + 'loadPref' => 'Load user preference value.', + 'savePref' => 'Save user preference value.', + 'delPref' => 'Delete user preference record.', + 'loadGroupPref' => 'Read group preference record.', + 'saveGroupPref' => 'Delete user preference record.', - 'getTransportInfo' => 'Common "check" method and info getter for transports', - 'turnOnOffTransports' => 'Turn transports on/off, optionaly return current state', - 'doTransportAction' => 'Pause, resume or cancel transport', - 'uploadFile2Hub' => 'Open async file transfer from local storageServer to network hub', - 'getHubInitiatedTransfers' => 'Get list of prepared transfers initiated by hub', + 'getTransportInfo' => 'Common "check" method and info getter for transports', + 'turnOnOffTransports' => 'Turn transports on/off, optionaly return current state', + 'doTransportAction' => 'Pause, resume or cancel transport', + 'uploadFile2Hub' => 'Open async file transfer from local storageServer to network hub', + 'getHubInitiatedTransfers' => 'Get list of prepared transfers initiated by hub', 'startHubInitiatedTransfer' => 'Start of download initiated by hub', - 'upload2Hub' => 'Start upload of audioclip or playlist from local storageServer to hub', - 'downloadFromHub' => 'Start download of audioclip or playlist from hub to local storageServer', - 'globalSearch' => 'Start search job on network hub', - 'getSearchResults' => 'Get results from search job on network hub', + 'upload2Hub' => 'Start upload of audioclip or playlist from local storageServer to hub', + 'downloadFromHub' => 'Start download of audioclip or playlist from hub to local storageServer', + 'globalSearch' => 'Start search job on network hub', + 'getSearchResults' => 'Get results from search job on network hub', + 'uploadOpen' => 'Open file-layer upload', + 'uploadCheck' => 'Check the checksum of uploaded file', + 'uploadClose' => 'Close file-layer upload', + 'downloadOpen' => 'Open file-layer download', +// 'downloadCheck' => 'Check the checksum of downloaded file', + 'downloadClose' => 'Close file-layer download', + 'prepareHubInitiatedTransfer' => 'Prepare hub initiated transfer', + 'listHubInitiatedTransfers' => 'List hub initiated transfers', + 'setHubInitiatedTransfer' => 'Set state of hub initiated transfers', + 'ping' => 'Echo request', ); $defs = array(); foreach ($methods as $method => $description) { $defs["locstor.$method"] = array( "function" => array(&$locStor, "xr_$method"), -# "function" => "\$GLOBALS['locStor']->xr_$method", "signature" => array( array($GLOBALS['XML_RPC_Struct'], $GLOBALS['XML_RPC_Struct']) ),