diff --git a/bin/upgrade-1.3-to-1.4.sql b/bin/upgrade-1.3-to-1.4.sql index 39cea5b36..81be48369 100644 --- a/bin/upgrade-1.3-to-1.4.sql +++ b/bin/upgrade-1.3-to-1.4.sql @@ -52,9 +52,19 @@ ALTER TABLE cc_files ALTER TABLE cc_files ADD COLUMN url character varying(1024); - - +ALTER TABLE cc_schedule RENAME playlist TO playlist_id; +ALTER TABLE cc_schedule ALTER playlist_id TYPE integer; +ALTER TABLE cc_schedule ADD COLUMN group_id integer; +ALTER TABLE cc_schedule ADD COLUMN file_id integer; +ALTER TABLE cc_schedule + ADD COLUMN fade_in time without time zone DEFAULT '00:00:00.000'; +ALTER TABLE cc_schedule + ADD COLUMN fade_out time without time zone DEFAULT '00:00:00.000'; +ALTER TABLE cc_schedule + ADD COLUMN cue_in time without time zone DEFAULT '00:00:00.000'; +ALTER TABLE cc_schedule + ADD COLUMN cue_out time without time zone DEFAULT '00:00:00.000'; +ALTER TABLE cc_schedule ADD CONSTRAINT unique_id UNIQUE (id); +CREATE SEQUENCE schedule_group_id_seq; - - \ No newline at end of file diff --git a/src/modules/htmlUI/var/ui_scheduler.class.php b/src/modules/htmlUI/var/ui_scheduler.class.php index af82639d7..486ab240b 100644 --- a/src/modules/htmlUI/var/ui_scheduler.class.php +++ b/src/modules/htmlUI/var/ui_scheduler.class.php @@ -1,4 +1,6 @@ spc =& SchedulerPhpClient::factory($mdefs, FALSE, FALSE); +// include_once(dirname(__FILE__).'/ui_schedulerPhpClient.class.php'); +// $this->spc =& SchedulerPhpClient::factory($mdefs, FALSE, FALSE); } // fn initXmlRpc @@ -1033,36 +1035,41 @@ class uiScheduler extends uiCalendar { $datetime = $formdata['date']['Y'] .sprintf('%02d', $formdata['date']['m']) .sprintf('%02d', $formdata['date']['d']) - .'T'.sprintf('%02d', $formdata['time']['H']) + .' '.sprintf('%02d', $formdata['time']['H']) .':'.sprintf('%02d', $formdata['time']['i']) .':'.sprintf('%02d', $formdata['time']['s']); - $r = $this->spc->UploadPlaylistMethod($this->Base->sessid, $gunid, $datetime); - if ($this->_isError($r)) { - return FALSE; - } - return TRUE; + $item = new ScheduleItem(); + $groupId = $item->add($datetime, $gunid); + return is_numeric($groupId); +// $r = $this->spc->UploadPlaylistMethod($this->Base->sessid, $gunid, $datetime); +// if ($this->_isError($r)) { +// return FALSE; +// } +// return TRUE; } // fn uploadPlaylistMethod /** - * Remove a playlist from the scheduler. + * Remove an item from the scheduler. * * @param string $id - * gunid of the playlist + * groupId of the item * @return boolean * TRUE on success, FALSE on failure. */ - function removeFromScheduleMethod($id) + function removeFromScheduleMethod($p_groupId) { - $r = $this->spc->removeFromScheduleMethod($this->Base->sessid, $id); - if ($this->_isError($r)) { - return FALSE; - } - if (UI_VERBOSE) { - $this->Base->_retMsg('Entry with ScheduleId $1 removed.', $id); - } - return TRUE; + $item = new ScheduleItem($p_groupId); + $success = $item->remove(); + //$r = $this->spc->removeFromScheduleMethod($this->Base->sessid, $id); + if (!$success) { + return FALSE; + } + if (UI_VERBOSE) { + $this->Base->_retMsg('Entry with ScheduleId $1 removed.', $id); + } + return TRUE; } // fn removeFromScheduleMethod @@ -1077,11 +1084,14 @@ class uiScheduler extends uiCalendar { */ function displayScheduleMethod($from, $to) { - $r = $this->spc->displayScheduleMethod($this->Base->sessid, $from, $to); - if ($this->_isError($r)) { - return FALSE; - } - return $r; + // NOTE: Need to fix times. + $items = Schedule::GetItems($from, $to); + return $items; +// $r = $this->spc->displayScheduleMethod($this->Base->sessid, $from, $to); +// if ($this->_isError($r)) { +// return FALSE; +// } +// return $r; } // fn displayScheduleMethod @@ -1260,6 +1270,7 @@ class uiScheduler extends uiCalendar { public function getSchedulerTime() { + return time(); static $first, $cached; if (!$first) { $first = time(); diff --git a/src/modules/storageServer/var/Schedule.php b/src/modules/storageServer/var/Schedule.php new file mode 100644 index 000000000..30d693868 --- /dev/null +++ b/src/modules/storageServer/var/Schedule.php @@ -0,0 +1,199 @@ +groupId = $p_groupId; + } + + /** + * Convert a date to an ID by stripping out all characters + * and padding with zeros. + * + * @param string $p_dateStr + */ + public static function dateToId($p_dateStr) { + $p_dateStr = str_replace(":", "", $p_dateStr); + $p_dateStr = str_replace(" ", "", $p_dateStr); + $p_dateStr = str_replace(".", "", $p_dateStr); + $p_dateStr = str_replace("-", "", $p_dateStr); + $p_dateStr = substr($p_dateStr, 0, 17); + $p_dateStr = str_pad($p_dateStr, 17, "0"); + return $p_dateStr; + } + + /** + * Add the two times together, return the result. + * + * @param string $p_baseTime + * Specified as YYYY-MM-DD HH:MM:SS + * + * @param string $p_addTime + * Specified as HH:MM:SS.nnnnnn + * + * @return string + * The end time, to the nearest second. + */ +// protected function calculateEndTime($p_startTime, $p_trackTime) { +// $p_trackTime = substr($p_startTime, 0, ); +// $start = new DateTime(); +// $interval = new DateInterval() +// +// } + + /** + * + * @param $p_audioFileId + * @param $p_playlistId + * @param $p_datetime + * @param $p_options + * @return int|null + * Return null if the item could not be added. + */ + public function add($p_datetime, $p_audioFileId = null, $p_playlistId = null, $p_options = null) { + global $CC_CONFIG, $CC_DBC; + if (!is_null($p_audioFileId)) { + // Schedule a single audio track + + // Load existing track + $track = StoredFile::Recall($p_audioFileId); + if (is_null($track)) { + return null; + } + + // Check if there are any conflicts with existing entries + $metadata = $track->getMetadata(); + $length = trim($metadata["length"]); + if (!Schedule::isScheduleEmptyInRange($p_datetime, $length)) { + return null; + } + + // Insert into the table + $this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')"); + $id = $this->dateToId($p_datetime); + $sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"] + ." (id, playlist_id, starts, ends, group_id, file_id)" + ." VALUES ($id, 0, TIMESTAMP '$p_datetime', " + ." (TIMESTAMP '$p_datetime' + INTERVAL '$length')," + ." {$this->groupId}, $p_audioFileId)"; + $CC_DBC->query($sql); + return $this->groupId; + + } elseif (!is_null($p_playlistId)){ + // Schedule a whole playlist + } + + // return group ID + } + + public function addAfter($p_groupId, $p_audioFileId) { + global $CC_CONFIG, $CC_DBC; + // Get the end time for the given entry + $sql = "SELECT ends FROM ".$CC_CONFIG["scheduleTable"] + ." WHERE group_id=$p_groupId"; + $startTime = $CC_DBC->GetOne($sql); + return $this->add($startTime, $p_audioFileId); + } + + public function update() { + + } + + /** + * Remove the group from the schedule. + * Note: does not check if it is in the past, you can remove anything. + * + * @return boolean + * TRUE on success, false if there is no group ID defined. + */ + public function remove() { + global $CC_CONFIG, $CC_DBC; + if (is_null($this->groupId) || !is_numeric($this->groupId)) { + return false; + } + $sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"] + ." WHERE group_id = ".$this->groupId; + return $CC_DBC->query($sql); + } + + public function reschedule($toDateTime) { + global $CC_CONFIG, $CC_DBC; +// $sql = "UPDATE ".$CC_CONFIG["scheduleTable"]. " SET id=, starts=,ends=" + } + +} + +class Schedule { + + function __construct() { + + } + + /** + * Return true if there is nothing in the schedule for the given times. + * + * @param string $p_datetime + * @param string $p_length + */ + public static function isScheduleEmptyInRange($p_datetime, $p_length) { + global $CC_CONFIG, $CC_DBC; + $sql = "SELECT COUNT(*) FROM ".$CC_CONFIG["scheduleTable"] + ." WHERE (starts <= '$p_datetime') " + ." AND (ends >= (TIMESTAMP '$p_datetime' + INTERVAL '$p_length'))"; + $count = $CC_DBC->GetOne($sql); + return ($count == '0'); + } + + public function onAddTrackToPlaylist($playlistId, $audioTrackId) { + + } + + public function onRemoveTrackFromPlaylist($playlistId, $audioTrackId) { + + } + + /** + * Returns array indexed numberically of: + * "playlistId" (gunid) + * "start" + * "end" + * "id" (DB id) + * + * @param $fromDateTime + * @param $toDateTime + */ + public static function GetItems($fromDateTime, $toDateTime, $playlistsOnly = true) { + global $CC_CONFIG, $CC_DBC; + $sql = "SELECT * FROM ".$CC_CONFIG["scheduleTable"] + ." WHERE (starts >= TIMESTAMP '$fromDateTime') " + ." AND (ends <= TIMESTAMP '$toDateTime')"; + $rows = $CC_DBC->GetAll($sql); + foreach ($rows as &$row) { + $row["playlistId"] = $row["playlist_id"]; + $row["start"] = $row["starts"]; + $row["end"] = $row["ends"]; + } + return $rows; + } + + function getSchedulerTime() { + + } + + function getCurrentlyPlaying() { + + } + + function getNextItem($nextCount = 1) { + + } + + function getStatus() { + + } + +} + +?> \ No newline at end of file diff --git a/src/modules/storageServer/var/StoredFile.php b/src/modules/storageServer/var/StoredFile.php index 11ff518e7..beec35242 100644 --- a/src/modules/storageServer/var/StoredFile.php +++ b/src/modules/storageServer/var/StoredFile.php @@ -1003,14 +1003,12 @@ class StoredFile { /** - * Get metadata as XML string + * Get metadata as array, indexed by the column names in the database. * - * @return XML string - * @see MetaData + * @return array */ public function getMetadata() { - //return $this->md->getMetadata(); return $this->md; } diff --git a/src/modules/storageServer/var/install/install.php b/src/modules/storageServer/var/install/install.php index dd7cee3d3..863fcb54b 100644 --- a/src/modules/storageServer/var/install/install.php +++ b/src/modules/storageServer/var/install/install.php @@ -371,11 +371,18 @@ if (!camp_db_table_exists($CC_CONFIG['transTable'])) { if (!camp_db_table_exists($CC_CONFIG['scheduleTable'])) { echo " * Creating database table ".$CC_CONFIG['scheduleTable']."..."; $sql = "CREATE TABLE ".$CC_CONFIG['scheduleTable']."(" - ." id BIGINT NOT NULL," - ." playlist BIGINT NOT NULL," - ." starts TIMESTAMP NOT NULL," - ." ends TIMESTAMP NOT NULL," - ." PRIMARY KEY(id))"; + ." id bigint NOT NULL," + ." playlist_id integer NOT NULL," + ." starts timestamp without time zone NOT NULL," + ." ends timestamp without time zone NOT NULL," + ." group_id integer," + ." file_id integer," + ." fade_in time without time zone DEFAULT '00:00:00'::time without time zone," + ." fade_out time without time zone DEFAULT '00:00:00'::time without time zone," + ." cue_in time without time zone DEFAULT '00:00:00'::time without time zone," + ." cue_out time without time zone DEFAULT '00:00:00'::time without time zone," + ." CONSTRAINT cc_schedule_pkey PRIMARY KEY (id)," + ." CONSTRAINT unique_id UNIQUE (id))"; camp_install_query($sql); } else { echo " * Skipping: database table already exists: ".$CC_CONFIG['scheduleTable']."\n"; diff --git a/src/modules/storageServer/var/install/uninstall.php b/src/modules/storageServer/var/install/uninstall.php index 6c781ace6..5b4243c47 100644 --- a/src/modules/storageServer/var/install/uninstall.php +++ b/src/modules/storageServer/var/install/uninstall.php @@ -107,7 +107,7 @@ if (camp_db_table_exists($CC_CONFIG['mdataTable'])) { if (camp_db_table_exists($CC_CONFIG['filesTable'])) { echo " * Removing database table ".$CC_CONFIG['filesTable']."..."; - $sql = "DROP TABLE ".$CC_CONFIG['filesTable']; + $sql = "DROP TABLE ".$CC_CONFIG['filesTable']." CASCADE"; camp_install_query($sql); $CC_DBC->dropSequence($CC_CONFIG['filesTable']."_id"); @@ -151,7 +151,7 @@ if (camp_db_table_exists($CC_CONFIG['subjTable'])) { echo " * Removing database table ".$CC_CONFIG['subjTable']."..."; $CC_DBC->dropSequence($CC_CONFIG['subjTable']."_id"); - $sql = "DROP TABLE ".$CC_CONFIG['subjTable']; + $sql = "DROP TABLE ".$CC_CONFIG['subjTable']." CASCADE"; camp_install_query($sql, false); echo "done.\n"; diff --git a/src/modules/storageServer/var/tests/0000000000010001.xml b/src/modules/storageServer/var/tests/0000000000010001.xml deleted file mode 100644 index 763d14b53..000000000 --- a/src/modules/storageServer/var/tests/0000000000010001.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - one - 00:00:11.000000 - - diff --git a/src/modules/storageServer/var/tests/0000000000010002.xml b/src/modules/storageServer/var/tests/0000000000010002.xml deleted file mode 100644 index 560d4fe0c..000000000 --- a/src/modules/storageServer/var/tests/0000000000010002.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - two - 00:00:12.200000 - - diff --git a/src/modules/storageServer/var/tests/AllTests.php b/src/modules/storageServer/var/tests/AllTests.php new file mode 100644 index 000000000..ea6a22b18 --- /dev/null +++ b/src/modules/storageServer/var/tests/AllTests.php @@ -0,0 +1,14 @@ +addTestSuite("SchedulerTests"); +$result = PHPUnit::run($suite); + +echo $result->toString(); + +?> \ No newline at end of file diff --git a/src/modules/storageServer/var/tests/UnitTests.php b/src/modules/storageServer/var/tests/BasicStorTests.php similarity index 93% rename from src/modules/storageServer/var/tests/UnitTests.php rename to src/modules/storageServer/var/tests/BasicStorTests.php index 4c9225e5a..7a232997b 100644 --- a/src/modules/storageServer/var/tests/UnitTests.php +++ b/src/modules/storageServer/var/tests/BasicStorTests.php @@ -1,7 +1,4 @@ greenbox = new GreenBox(); @@ -42,6 +39,7 @@ class BasicStorTest extends PHPUnit_TestCase { $this->fail("Metadata has unexpected values:\n".$str); } //var_dump($metadata); + //$this->assertTrue(FALSE); } function testPutFile() { diff --git a/src/modules/storageServer/var/tests/mdata1.xml b/src/modules/storageServer/var/tests/mdata1.xml deleted file mode 100644 index 996d33080..000000000 --- a/src/modules/storageServer/var/tests/mdata1.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - File Title txt - Alternative File Title ín sőmé %$#@* LÁNGŰAGÉ - Keywords: qwe, asd, zcx - Abstract txt - 2004-05-21 - Folk - audio/mpeg - 00:00:03.000000 - - gunid here - Spatial Coverage - Temporal Covarage - János Kőbor - - diff --git a/src/modules/storageServer/var/tests/mdata10001.xml b/src/modules/storageServer/var/tests/mdata10001.xml deleted file mode 100644 index 763d14b53..000000000 --- a/src/modules/storageServer/var/tests/mdata10001.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - one - 00:00:11.000000 - - diff --git a/src/modules/storageServer/var/tests/mdata10002.xml b/src/modules/storageServer/var/tests/mdata10002.xml deleted file mode 100644 index 560d4fe0c..000000000 --- a/src/modules/storageServer/var/tests/mdata10002.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - two - 00:00:12.200000 - - diff --git a/src/modules/storageServer/var/tests/mdata10003.xml b/src/modules/storageServer/var/tests/mdata10003.xml deleted file mode 100644 index 98582b547..000000000 --- a/src/modules/storageServer/var/tests/mdata10003.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - three - 00:00:11.500000 - - diff --git a/src/modules/storageServer/var/tests/mdata2.xml b/src/modules/storageServer/var/tests/mdata2.xml deleted file mode 100644 index b277fecab..000000000 --- a/src/modules/storageServer/var/tests/mdata2.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - File2 Title txt - Alternative File2 Title txt - Keywords: qwe, asd, zcx - Abstract txt - 2004-05-21 - audio/mpeg - 00:10:00.000000 - - gunid here - Spatial Coverage - Temporal Covarage - John X2 - - diff --git a/src/modules/storageServer/var/tests/mdata3.xml b/src/modules/storageServer/var/tests/mdata3.xml deleted file mode 100644 index b5d091f99..000000000 --- a/src/modules/storageServer/var/tests/mdata3.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - Fil Title3 txt - Alternative File Title txt - 00:01:00.000000 - John Y - - diff --git a/src/modules/storageServer/var/tests/mdataVal1.xml b/src/modules/storageServer/var/tests/mdataVal1.xml deleted file mode 100644 index baf4becd4..000000000 --- a/src/modules/storageServer/var/tests/mdataVal1.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - File Title4 utf-8 - ěščřžýáíé ĚŠČŘŽÝÁÍÉ úůÚŮ ďťňĎŤŇ é - 00:00:10.000000 - John Y - - diff --git a/src/modules/storageServer/var/tests/plist1.xml b/src/modules/storageServer/var/tests/plist1.xml deleted file mode 100644 index 036957e18..000000000 --- a/src/modules/storageServer/var/tests/plist1.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - My First Playlist - Me, myself and I - 01:30:00.000000 - - diff --git a/src/modules/storageServer/var/tests/plist2.xml b/src/modules/storageServer/var/tests/plist2.xml deleted file mode 100644 index aefe06dd7..000000000 --- a/src/modules/storageServer/var/tests/plist2.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - My Second Playlist - Nobody - 00:00:29.700000 - - diff --git a/src/modules/storageServer/var/tests/runUnitTests.php b/src/modules/storageServer/var/tests/runUnitTests.php deleted file mode 100644 index 9393f37b6..000000000 --- a/src/modules/storageServer/var/tests/runUnitTests.php +++ /dev/null @@ -1,9 +0,0 @@ -toString(); -?> \ No newline at end of file diff --git a/src/modules/storageServer/var/tests/sampleData.php b/src/modules/storageServer/var/tests/sampleData.php deleted file mode 100644 index 2c8cdcc2b..000000000 --- a/src/modules/storageServer/var/tests/sampleData.php +++ /dev/null @@ -1,59 +0,0 @@ - 'audioclip', - 'media' => '../tests/test10001.mp3', - 'xml' => '../tests/mdata10001.xml', - 'gunid' => '0000000000010001' - ), - array( - 'type' => 'audioclip', - 'media' => '../tests/test10002.mp3', - 'xml' => '../tests/mdata10002.xml', - 'gunid' => '0000000000010002' - ), - array( - 'type' => 'audioclip', - 'media' => '../tests/test10003.mp3', - 'xml' => '../tests/mdata10003.xml', - 'gunid' => '0000000000010003' - ), - array( - 'type' => 'audioclip', - 'media' => '../tests/ex1.mp3', - 'xml' => '../tests/mdata1.xml', - 'gunid' => '123456789abcdef1' - ), - array( - 'type' => 'audioclip', - 'media' => '../tests/ex2.ogg', - 'xml' => '../tests/mdata2.xml', - 'gunid' => '123456789abcdef2' - ), - array( - 'type' => 'audioclip', - 'media' => '../tests/ex3.wav', - 'xml' => '../tests/mdata3.xml' - ), - array( - 'type' => 'playlist', - 'xml' => '../tests/plist1.xml', - 'gunid' => '0000000000000001' - ), - array( - 'type' => 'playlist', - 'xml' => '../tests/plist2.xml', - 'gunid' => '0000000000000002' - ), - array( - 'type' => 'playlist', - 'xml' => '../tests/plistEmbedded.xml', - 'gunid' => '0000000000000003' - ), - array( - 'type' => 'webstream', - 'xml' => '../tests/wstream1.xml', - 'gunid' => 'f000000000000001' - ) - ); -?> diff --git a/src/modules/storageServer/var/tests/testStorage.xml b/src/modules/storageServer/var/tests/testStorage.xml deleted file mode 100644 index 4b7a4066c..000000000 --- a/src/modules/storageServer/var/tests/testStorage.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - -]> - - - diff --git a/src/modules/storageServer/var/tests/transTest.php b/src/modules/storageServer/var/tests/transTest.php index ae8c7313a..3c93252f3 100644 --- a/src/modules/storageServer/var/tests/transTest.php +++ b/src/modules/storageServer/var/tests/transTest.php @@ -1,4 +1,5 @@ 'php', 'prefix' => "Campcaster_Remote.")); -////var_dump($client); -//$result = $client->System_Ping("woo"); -//var_dump($result); -exit; - -/* ========== STORE ========== */ +// ========== STORE ========== echo"# Store: "; //$parid = $gb->_getHomeDirIdFromSess($sessid); @@ -57,7 +52,7 @@ $oid = $storedFile->getId(); $comm = "ls -l ".$CC_CONFIG['storageDir']."/a23"; echo `$comm`; echo "$oid\n"; -/* ========== DELETE FROM HUB ========== */ +// ========== DELETE FROM HUB ========== echo"# loginToArchive: "; $r = $tr->loginToArchive(); if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()." / ".$r->getUserInfo()."\n"; exit(1); } @@ -80,7 +75,7 @@ if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()." / ".$r->getUserInfo()." var_export($r); echo"\n"; -/* ========== UPLOAD ========== */ +// ========== UPLOAD ========== echo "# UPLOAD test:\n"; echo"# uploadAudioClip2Hub: "; $r = $gb->upload2Hub($gunid); @@ -91,16 +86,9 @@ $trtok = $r; echo"# logout: "; $r = Alib::Logout($sessid); if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); } echo "$r\n"; -/* -*/ #$trtok='280a6f1c18389620'; for($state='', $nu=1; ($state!='closed' && $state!='failed' && $nu<=12); $nu++, sleep(2)){ -/* - echo"# $nu: Transport: cronMain: "; $r = $tr->cronMain(); - if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); } - var_export($r); echo"\n"; -*/ echo"# getTransportInfo: "; $r = $gb->getTransportInfo($trtok); if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); } $state = $r['state']; @@ -108,7 +96,7 @@ for($state='', $nu=1; ($state!='closed' && $state!='failed' && $nu<=12); $nu++, } if($state=='failed') exit(1); -/* === DELETE LOCAL === */ +// === DELETE LOCAL === echo "# Login: ".($sessid = Alib::Login('root', 'q'))."\n"; echo "# Delete: "; $r = $ls->deleteAudioClip($sessid, $gunid, TRUE); if (PEAR::isError($r)) { @@ -124,14 +112,8 @@ if (PEAR::isError($r)) { echo "$r\n"; $comm = "ls -l ".$CC_CONFIG['storageDir']."/a23"; echo `$comm`; -/* -*/ -#echo"TMPEND\n"; exit; -#echo `tail -n 25 ../trans/log`; exit; -#$sleeptime=10; echo "sleep $sleeptime\n"; sleep($sleeptime); - -/* === DOWNLOAD === */ +// === DOWNLOAD === echo "# DOWNLOAD test:\n"; echo"# Login: ".($sessid = Alib::Login('root', 'q'))."\n"; @@ -146,11 +128,6 @@ if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); } echo "$r\n"; for($state='', $nu=1; ($state!='closed' && $state!='failed' && $nu<=12); $nu++, sleep(2)){ -/* - echo"# $nu: Transport: cronMain: "; $r = $tr->cronMain(); - if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); } - var_export($r); echo"\n"; -*/ echo"# getTransportInfo: "; $r = $gb->getTransportInfo($trtok); if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); } $state = $r['state']; @@ -159,40 +136,8 @@ for($state='', $nu=1; ($state!='closed' && $state!='failed' && $nu<=12); $nu++, if($state=='failed') exit(1); $comm = "ls -l ".$CC_CONFIG['storageDir']."/a23"; echo `$comm`; -/* -*/ - -/* -echo"# Login: ".($sessid = Alib::Login('root', 'q'))."\n"; -echo"# Delete: "; $r = $ls->deleteAudioClip($sessid, $gunid, TRUE); -if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); } -echo "$r\n"; -echo"# logout: "; $r = Alib::Logout($sessid); -if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); } -echo "$r\n"; -*/ - -#echo `tail -n 20 ../trans/log`; exit; - -/* -echo"# Transport loginToArchive: "; $r = $tr->loginToArchive(); -if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); } -var_export($r['sessid']); echo"\n"; - -echo"# Transport logoutFromArchive: "; $r = $tr->logoutFromArchive($r['sessid']); -if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); } -var_export($r['status']); echo"\n"; - -echo"# Ping: "; -$r = $tr->ping(); -if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); } -var_export($r); echo"\n"; - -echo"# Delete: "; $r = $gb->deleteAudioClip($sessid, $gunid); -if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); } -echo "$r\n"; -*/ if(file_exists("../trans/log")) echo `tail -n 25 ../trans/log`; -echo "#Transport test: OK.\n\n" +echo "#Transport test: OK.\n\n"; +*/ ?> \ No newline at end of file diff --git a/src/modules/storageServer/var/tests/transTest.sh b/src/modules/storageServer/var/tests/transTest.sh deleted file mode 100755 index 5e51dca0d..000000000 --- a/src/modules/storageServer/var/tests/transTest.sh +++ /dev/null @@ -1,222 +0,0 @@ -#!/bin/bash -#------------------------------------------------------------------------------- -# Copyright (c) 2010 Sourcefabric O.P.S. -# -# This file is part of the Campcaster project. -# http://campcaster.campware.org/ -# -# Campcaster is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# Campcaster is distributed in the hope that it will be useful, -# 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 Campcaster; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# This script call locstor.resetStorage XMLRPC method -#------------------------------------------------------------------------------- - -reldir=`dirname $0`/../.. -WWW_ROOT=`cd $reldir/var/install; php -q getWwwRoot.php` || exit $? -echo "#Transport test: URL: $WWW_ROOT" - -#$reldir/var/xmlrpc/xr_cli_test.py -s $WWW_ROOT/xmlrpc/xrLocStor.php \ -# resetStorage || exit $? - -cd $reldir/var/xmlrpc -XR_CLI="php -q xr_cli_test.php -s $WWW_ROOT/xmlrpc/xrLocStor.php" - -#------------------------------------------------------------------------------- -# storage related functions -#------------------------------------------------------------------------------- -login() { - echo -n "# login: " - SESSID=`$XR_CLI login root q` || \ - { ERN=$?; echo $SESSID; exit $ERN; } - echo "sessid: $SESSID" -} - -storeOpenClose() { - GUNID=$1 ; shift - [[ "x$1" != "x" ]] && MEDIA="$1" || MEDIA="../tests/ex1.mp3" - shift - [[ "x$1" != "x" ]] && METADATA=`cat "$1"` || METADATA=" - - 00:00:11.000000 - Transport test file 1 - " - #echo "# store: gunid=$GUNID mediafile=$MEDIA metadata=$METADATA" - echo "# store: " - MD5=`md5sum $MEDIA`; for i in $MD5; do MD5=$i; break; done - RES=`$XR_CLI storeAudioClipOpen "$SESSID" "$GUNID" "$METADATA" "stored_file.mp3" "$MD5"` || \ - { ERN=$?; echo $RES; exit $ERN; } - unset URL - for i in $RES; do if [ -z $URL ] ; then URL=$i; else TOKEN=$i; fi; done - echo " URL = $URL" - echo " TOKEN = $TOKEN" - echo -n "# curl (PUT): " - curl -C 0 -T $MEDIA $URL || exit $? - echo "status: $?" - echo -n "# storeAudioClipClose: " - GUNID=`$XR_CLI storeAudioClipClose "$SESSID" "$TOKEN"` || \ - { ERN=$?; echo $GUNID; exit $ERN; } - echo $GUNID -} - -deleteAudioClip() { - GUNID=$1 ; shift - echo -n "# deleteAudioClip: " - $XR_CLI deleteAudioClip $SESSID $GUNID 1 -} - -#------------------------------------------------------------------------------- -# transport related functions -#------------------------------------------------------------------------------- -getTransportInfo() { - TRTOK=$1 ; shift - echo "# getTransportInfo:" - $XR_CLI getTransportInfo $TRTOK - echo "# status: $?" -} - -upload2Hub() { - GUNID=$1 ; shift - echo -n "# upload2Hub: ($GUNID)" - TRTOK=`$XR_CLI upload2Hub $SESSID $GUNID` || \ - { ERN=$?; echo $TRTOK; exit $ERN; } - echo $TRTOK -} - -downloadFromHub() { - GUNID=$1 ; shift - echo -n "# downloadFromHub: ($GUNID)" - TRTOK=`$XR_CLI downloadFromHub $SESSID $GUNID` || \ - { ERN=$?; echo $TRTOK; exit $ERN; } - echo $TRTOK -} - -uploadFile2Hub() { - FILE=$1 ; shift - echo -n "# uploadFile2Hub: " - TRTOK=`$XR_CLI uploadFile2Hub $SESSID $FILE` || \ - { ERN=$?; echo $TRTOK; exit $ERN; } - echo $TRTOK -} - -getHubInitiatedTransfers() { - echo -n "# getHubInitiatedTransfers: " - TRTOK=`$XR_CLI getHubInitiatedTransfers $SESSID` || \ - { ERN=$?; echo $TRTOK; exit $ERN; } - echo $TRTOK -} - -startHubInitiatedTransfer() { - TRTOK=$1 ; shift - echo -n "# startHubInitiatedTransfer: " - RES=`$XR_CLI startHubInitiatedTransfer $TRTOK` || \ - { ERN=$?; echo $TRTOK; exit $ERN; } - echo $RES -} - -transportCron() { - echo -n "# transportCron: " - ../cron/transportCron.php - echo $? -} - -logout() { - echo -n "# logout: " - $XR_CLI logout $SESSID || exit $? -} - -#------------------------------------------------------------------------------- -# playlist related functions -#------------------------------------------------------------------------------- -PLID="123456789abcdef8" - -createPlaylistAndEdit() { - PLID=$1 ; shift - echo -n "# createPlaylist: " - $XR_CLI createPlaylist $SESSID $PLID "newPlaylist.xml" || exit $? - DATE=`date '+%H:%M:%S'` - [[ "x$1" != "x" ]] && PLAYLIST=`cat "$1"` || PLAYLIST=" - - XY $DATE - 00:00:01.000000 - - - - - - - -" - echo -n "# editPlaylist: " - RES=`$XR_CLI editPlaylist $SESSID $PLID` || \ - { ERN=$?; echo $RES; exit $ERN; } - unset URL - for i in $RES; do if [ -z $URL ] ; then URL=$i; else TOKEN=$i; fi; done - echo $TOKEN -# deletePlaylist - if [ $DEBUG_I ]; then echo $URL; fi - if [ $DEBUG_I ]; then echo -n "Press enter ..."; read KEY; fi - if [ $DEBUG_I ]; then echo " Playlist:"; echo $PLAYLIST; fi - echo -n "# savePlaylist: " - $XR_CLI savePlaylist $SESSID $TOKEN "$PLAYLIST" || exit $? -} - -deletePlaylist() { - PLID=$1 ; shift - echo -n "# deletePlaylist (${PLID}): " - $XR_CLI deletePlaylist $SESSID $PLID 1 - # || exit $? - echo "# status: $?" -} - - -#------------------------------------------------------------------------------- -# executable part -#------------------------------------------------------------------------------- -GUNID_="a23456789abcdef3" -PLID_=$GUNID_ -MEDIA_="../tests/ex1.mp3" - -login -for i in 0000000000010001 0000000000010002; do echo $i - storeOpenClose $i "../tests/$i" "../tests/$i.xml" -done - -deletePlaylist $PLID_ -deletePlaylist $PLID_ -createPlaylistAndEdit $PLID_ "../tests/0000000000000001.xml" - -upload2Hub $PLID_ -for i in $(seq 5); do getTransportInfo $TRTOK; sleep 1; done - -#sleep 10 -for i in 0000000000010001 0000000000010002; do echo $i - deleteAudioClip $i -done -deletePlaylist $PLID_ - -echo "STOP - press ENTER"; read key - -downloadFromHub $PLID_ -for i in $(seq 5); do getTransportInfo $TRTOK; sleep 1; done - -logout - -echo "#Transport test: OK" -exit 0 diff --git a/src/modules/storageServer/var/tests/webstreamTest.php b/src/modules/storageServer/var/tests/webstreamTest.php index 415175b85..2821ba927 100644 --- a/src/modules/storageServer/var/tests/webstreamTest.php +++ b/src/modules/storageServer/var/tests/webstreamTest.php @@ -1,4 +1,5 @@ \ No newline at end of file