From 577fd9edf02ff8c6488144ef1b50fa5f722b11ff Mon Sep 17 00:00:00 2001 From: rubenrua Date: Mon, 12 Jun 2017 12:14:14 +0200 Subject: [PATCH 1/5] Use /info/components.json service to get the admin URL. See commit e3f470739e690863eeb0c6d7566fc04c14c7c4c3 --- .../OpencastBundle/Services/ClientService.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Pumukit/OpencastBundle/Services/ClientService.php b/src/Pumukit/OpencastBundle/Services/ClientService.php index a8be6e372..f3fcc270d 100644 --- a/src/Pumukit/OpencastBundle/Services/ClientService.php +++ b/src/Pumukit/OpencastBundle/Services/ClientService.php @@ -95,14 +95,13 @@ public function getAdminUrl() return $this->adminUrl; } - $output = $this->request('/services/available.json?serviceType=org.opencastproject.episode'); + $output = $this->request('/info/components.json'); $decode = $this->decodeJson($output['var']); - if (isset($decode['services'])) { - if (isset($decode['services']['service'])) { - if (isset($decode['services']['service']['host'])) { - $this->adminUrl = $decode['services']['service']['host']; - } - } + + if (isset($decode['admin']) && + filter_var($decode['admin'], FILTER_VALIDATE_URL)) { + + $this->adminUrl = $decode['admin']; } return $this->adminUrl; @@ -207,7 +206,11 @@ public function getMediapackageFromArchive($id) $output = $this->request('/episode/episode.json?id='.$id, array(), 'GET', true); if ($output['status'] !== 200) { - return false; + $output = $this->request('/archive/episode.json?id='.$id, array(), 'GET', true); + + if ($output['status'] !== 200) { + return false; + } } $decode = $this->decodeJson($output['var']); From 85b5afaf538dda5cdecd2f80e29d530106ecad61 Mon Sep 17 00:00:00 2001 From: rubenrua Date: Mon, 12 Jun 2017 12:16:09 +0200 Subject: [PATCH 2/5] Fix typo with pumukit_opencast.use_redirect See commit 8cb892a23d236eed0dc34bdd2d57cb6f05f2507b --- src/Pumukit/WebTVBundle/Controller/OpencastController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pumukit/WebTVBundle/Controller/OpencastController.php b/src/Pumukit/WebTVBundle/Controller/OpencastController.php index 336f0028e..56ccec9d6 100644 --- a/src/Pumukit/WebTVBundle/Controller/OpencastController.php +++ b/src/Pumukit/WebTVBundle/Controller/OpencastController.php @@ -44,7 +44,7 @@ public function doAction(MultimediaObject $multimediaObject, Request $request) } $mmobjService = $this->get('pumukitschema.multimedia_object'); - if ($this->container->hasParameter('pumukit.opencast.use_redirect') && $this->container->getParameter('pumukit.opencast.use_redirect')) { + if ($this->container->hasParameter('pumukit_opencast.use_redirect') && $this->container->getParameter('pumukit_opencast.use_redirect')) { $event = new ViewedEvent($multimediaObject, null); $this->get('event_dispatcher')->dispatch(BasePlayerEvents::MULTIMEDIAOBJECT_VIEW, $event); if ($invert = $multimediaObject->getProperty('opencastinvert')) { From 2861d164cf695ecf3f01e926dd9e46d4f1baea72 Mon Sep 17 00:00:00 2001 From: rubenrua Date: Mon, 12 Jun 2017 12:17:53 +0200 Subject: [PATCH 3/5] Fix bug related with pumukit_opencast.use_redirect See commit ed005a669d725a023c85b1c061310e195feeced5 --- src/Pumukit/WebTVBundle/Controller/OpencastController.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Pumukit/WebTVBundle/Controller/OpencastController.php b/src/Pumukit/WebTVBundle/Controller/OpencastController.php index 56ccec9d6..63e0147a0 100644 --- a/src/Pumukit/WebTVBundle/Controller/OpencastController.php +++ b/src/Pumukit/WebTVBundle/Controller/OpencastController.php @@ -16,6 +16,10 @@ class OpencastController extends PlayerController implements WebTVController public function magicAction(MultimediaObject $multimediaObject, Request $request) { $array = $this->doAction($multimediaObject, $request); + if ($array instanceof Response) { + return $array; + } + $array['magic_url'] = true; $array['cinema_mode'] = $this->getParameter('pumukit_web_tv.cinema_mode'); @@ -30,6 +34,10 @@ public function magicAction(MultimediaObject $multimediaObject, Request $request public function indexAction(MultimediaObject $multimediaObject, Request $request) { $array = $this->doAction($multimediaObject, $request); + if ($array instanceof Response) { + return $array; + } + $array['cinema_mode'] = $this->getParameter('pumukit_web_tv.cinema_mode'); return $this->render('PumukitWebTVBundle:MultimediaObject:index.html.twig', From 4710a73ad4ffe026543378e771c927e982c23934 Mon Sep 17 00:00:00 2001 From: rubenrua Date: Mon, 12 Jun 2017 12:38:26 +0200 Subject: [PATCH 4/5] Throw exception when directory does not exist. See commit c87469f6571556d1c771c3f2a3bb56ddf9a3558d --- .../DependencyInjection/Configuration.php | 4 ++++ .../DependencyInjection/PumukitOpencastExtension.php | 12 +++++++++++- .../Resources/doc/ConfigurationGuide.md | 2 ++ .../OpencastBundle/Services/ClientService.php | 1 - .../OpencastBundle/Services/OpencastService.php | 11 ++++++++++- 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/Pumukit/OpencastBundle/DependencyInjection/Configuration.php b/src/Pumukit/OpencastBundle/DependencyInjection/Configuration.php index fbfc66939..0134cf624 100644 --- a/src/Pumukit/OpencastBundle/DependencyInjection/Configuration.php +++ b/src/Pumukit/OpencastBundle/DependencyInjection/Configuration.php @@ -49,6 +49,10 @@ public function getConfigTreeBuilder() ->defaultTrue() ->info('Video will be redirected for being played at Opencast server, otherwise it will be iframed in Pumukit.') ->end() + ->booleanNode('error_if_file_not_exist') + ->defaultTrue() + ->info('Throw an error if the track file doesn\'t exist or it is not accessible using the url_mapping info.') + ->end() ->booleanNode('batchimport_inverted') ->defaultFalse() ->info('Opencast videos will be imported with presentation and presented inverted, switching positions, if set to true.') diff --git a/src/Pumukit/OpencastBundle/DependencyInjection/PumukitOpencastExtension.php b/src/Pumukit/OpencastBundle/DependencyInjection/PumukitOpencastExtension.php index 5b9122c85..fdb437ae2 100644 --- a/src/Pumukit/OpencastBundle/DependencyInjection/PumukitOpencastExtension.php +++ b/src/Pumukit/OpencastBundle/DependencyInjection/PumukitOpencastExtension.php @@ -32,6 +32,15 @@ public function load(array $configs, ContainerBuilder $container) $config['host'])); } + foreach ($config['url_mapping'] as $m) { + if (!realpath($m['path'])) { + throw new \RuntimeException(sprintf( + 'The "%s" directory does not exist. Check "pumukit_opencast.url_mapping".', + $m['path'] + )); + } + } + $container ->register('pumukit_opencast.client', "Pumukit\OpencastBundle\Services\ClientService") ->addArgument($config['host']) @@ -55,7 +64,8 @@ public function load(array $configs, ContainerBuilder $container) ->addArgument(new Reference('pumukitschema.multimedia_object')) ->addArgument($config['sbs']) ->addArgument($config['url_mapping']) - ->addArgument(array('opencast_host' => $config['host'], 'opencast_username' => $config['username'], 'opencast_password' => $config['password'])); + ->addArgument(array('opencast_host' => $config['host'], 'opencast_username' => $config['username'], 'opencast_password' => $config['password'])) + ->addArgument($config['error_if_file_not_exist']); $container ->register('pumukit_opencast.import', "Pumukit\OpencastBundle\Services\OpencastImportService") diff --git a/src/Pumukit/OpencastBundle/Resources/doc/ConfigurationGuide.md b/src/Pumukit/OpencastBundle/Resources/doc/ConfigurationGuide.md index 3b015524e..2e13a979c 100644 --- a/src/Pumukit/OpencastBundle/Resources/doc/ConfigurationGuide.md +++ b/src/Pumukit/OpencastBundle/Resources/doc/ConfigurationGuide.md @@ -27,6 +27,7 @@ pumukit_opencast: profile: sbs use_flavour: true flavour: composition/delivery + error_if_file_not_exist: true url_mapping: - url: 'http://demo.opencast.org/static/engage-player/' @@ -53,6 +54,7 @@ Optional: - `profile` is the profile name to generate the side by side video. Mandatory if `generate_sbs` is set to true. - `use_flavour` when set to true, it will use a Track with given below flavour as side by side track. Default value: false. - `flavour` is the name of the flavour of an Opencast track to be used as side by side track in PuMuKIT. Default value: composition/delivery. + - `error_if_file_not_exist` throw an error if the track file doesn't exist or it is not accessible using the url mapping info. Default value: true. - `url_mappging` is a list of url-path mappging used to generate the side by side video. Mandatory if `generate_sbs` is set to true. - `url` is the internal URL of the Opencast Matterhorn installation, used by Matterhorn to locate services running on the instance and for inter-node communication in distributed setups involving more than one Matterhorn node (org.opencastproject.server.url). - `path` is the directory where the system will store its processed files (including temporary files). This directory should be persistent between reboots (i.e., not /tmp) (org.opencastproject.storage.dir). diff --git a/src/Pumukit/OpencastBundle/Services/ClientService.php b/src/Pumukit/OpencastBundle/Services/ClientService.php index f3fcc270d..960c7f2e1 100644 --- a/src/Pumukit/OpencastBundle/Services/ClientService.php +++ b/src/Pumukit/OpencastBundle/Services/ClientService.php @@ -100,7 +100,6 @@ public function getAdminUrl() if (isset($decode['admin']) && filter_var($decode['admin'], FILTER_VALIDATE_URL)) { - $this->adminUrl = $decode['admin']; } diff --git a/src/Pumukit/OpencastBundle/Services/OpencastService.php b/src/Pumukit/OpencastBundle/Services/OpencastService.php index aec25fa6d..8f33b7475 100644 --- a/src/Pumukit/OpencastBundle/Services/OpencastService.php +++ b/src/Pumukit/OpencastBundle/Services/OpencastService.php @@ -20,8 +20,9 @@ class OpencastService private $profileService; private $multimediaObjectService; private $defaultVars; + private $errorIfFileNotExist; - public function __construct(JobService $jobService, ProfileService $profileService, MultimediaObjectService $multimediaObjectService, array $sbsConfiguration = array(), array $urlMapping = array(), array $defaultVars = array()) + public function __construct(JobService $jobService, ProfileService $profileService, MultimediaObjectService $multimediaObjectService, array $sbsConfiguration = array(), array $urlMapping = array(), array $defaultVars = array(), $errorIfFileNotExist = true) { $this->jobService = $jobService; $this->profileService = $profileService; @@ -29,6 +30,7 @@ public function __construct(JobService $jobService, ProfileService $profileServi $this->sbsConfiguration = $sbsConfiguration; $this->urlPathMapping = $urlMapping; $this->defaultVars = $defaultVars; + $this->errorIfFileNotExist = $errorIfFileNotExist; $this->initSbsConfiguration(); } @@ -97,6 +99,13 @@ public function getPath($url) } } + if ($this->errorIfFileNotExist) { + throw new \RuntimeException(sprintf( + 'Error accessing to the track path of "%s". Check "pumukit_opencast.url_mapping".', + $url + )); + } + return null; } From 91c8fe6b67fc960c47bb7d52e2a7b0a491ae8a5f Mon Sep 17 00:00:00 2001 From: rubenrua Date: Mon, 12 Jun 2017 12:41:28 +0200 Subject: [PATCH 5/5] Add embed mode parameter into opencasturl See commit 58e3935220964c67acec428d49e5ddc8980bd478 --- src/Pumukit/OpencastBundle/Services/OpencastImportService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pumukit/OpencastBundle/Services/OpencastImportService.php b/src/Pumukit/OpencastBundle/Services/OpencastImportService.php index d9862660b..c58c4b86c 100644 --- a/src/Pumukit/OpencastBundle/Services/OpencastImportService.php +++ b/src/Pumukit/OpencastBundle/Services/OpencastImportService.php @@ -85,7 +85,7 @@ public function importRecording($opencastId, $invert = false, User $loggedInUser $properties = $this->getMediaPackageField($mediaPackage, 'id'); if ($properties) { $multimediaObject->setProperty('opencast', $properties); - $multimediaObject->setProperty('opencasturl', $this->opencastClient->getPlayerUrl().'?id='.$properties); + $multimediaObject->setProperty("opencasturl", $this->opencastClient->getPlayerUrl() . "?mode=embed&id=" . $properties); } $multimediaObject->setProperty('opencastinvert', boolval($invert));